7 /* dotlock file as user
9 /* #include <dot_lockfile_as.h>
11 /* int dot_lockfile_as(path, why, euid, egid)
17 /* void dot_unlockfile_as(path, euid, egid)
22 /* dot_lockfile_as() and dot_unlockfile_as() are wrappers around
23 /* the dot_lockfile() and dot_unlockfile() routines. The routines
24 /* change privilege to the designated privilege, perform the
25 /* requested operation, and restore privileges.
27 /* Fatal error: no permission to change privilege level.
29 /* dot_lockfile(3) dotlock file management
30 /* set_eugid(3) switch effective rights
34 /* The Secure Mailer license must be distributed with this software.
37 /* IBM T.J. Watson Research
39 /* Yorktown Heights, NY 10598, USA
47 /* Utility library. */
50 #include "set_eugid.h"
51 #include "dot_lockfile.h"
52 #include "dot_lockfile_as.h"
54 /* dot_lockfile_as - dotlock file as user */
56 int dot_lockfile_as(const char *path
, VSTRING
*why
, uid_t euid
, gid_t egid
)
58 uid_t saved_euid
= geteuid();
59 gid_t saved_egid
= getegid();
63 * Switch to the target user privileges.
65 set_eugid(euid
, egid
);
70 result
= dot_lockfile(path
, why
);
73 * Restore saved privileges.
75 set_eugid(saved_euid
, saved_egid
);
80 /* dot_unlockfile_as - dotlock file as user */
82 void dot_unlockfile_as(const char *path
, uid_t euid
, gid_t egid
)
84 uid_t saved_euid
= geteuid();
85 gid_t saved_egid
= getegid();
88 * Switch to the target user privileges.
90 set_eugid(euid
, egid
);
98 * Restore saved privileges.
100 set_eugid(saved_euid
, saved_egid
);