Lines Matching refs:uid
6 * Code for uid-swapping.
49 /* Saved effective uid. */
54 /* Saved effective uid. */
61 * Temporarily changes to the given uid. If the effective user
122 /* Set the effective uid to the given (unprivileged) uid. */
129 /* Propagate the privileged uid to all of our uids. */
142 permanently_drop_suid(uid_t uid)
146 debug("permanently_drop_suid: %u", (u_int)uid);
148 if (setresuid(uid, uid, uid) < 0)
149 fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno));
151 if (setreuid(uid, uid) < 0)
152 fatal("setreuid %u: %.100s", (u_int)uid, strerror(errno));
155 if (seteuid(uid) < 0)
156 fatal("seteuid %u: %.100s", (u_int)uid, strerror(errno));
158 if (setuid(uid) < 0)
159 fatal("setuid %u: %.100s", (u_int)uid, strerror(errno));
163 /* Try restoration of UID if changed (test clearing of saved uid) */
164 if (old_uid != uid &&
166 fatal("%s: was able to restore old [e]uid", __func__);
169 /* Verify UID drop was successful */
170 if (getuid() != uid || geteuid() != uid) {
171 fatal("%s: euid incorrect uid:%u euid:%u (should be %u)",
172 __func__, (u_int)getuid(), (u_int)geteuid(), (u_int)uid);
177 * Restores to the original (privileged) uid.
192 /* Set the effective uid back to the saved privileged uid. */
199 * We are unable to restore the real uid to its unprivileged value.
200 * Propagate the real uid (usually more privileged) to effective uid
213 * Permanently sets all uids to the given uid. This cannot be
307 /* Try restoration of UID if changed (test clearing of saved uid) */
310 fatal("%s: was able to restore old [e]uid", __func__);
313 /* Verify UID drop was successful */
315 fatal("%s: euid incorrect uid:%u euid:%u (should be %u)",