/* -*-c-*-
*
- * $Id: become.c,v 1.2 1997/08/04 10:24:20 mdw Exp $
+ * $Id: become.c,v 1.3 1997/08/07 16:28:59 mdw Exp $
*
* Main code for `become'
*
/*----- Revision history --------------------------------------------------*
*
* $Log: become.c,v $
+ * Revision 1.3 1997/08/07 16:28:59 mdw
+ * Do something useful when users attempt to become themselves.
+ *
* Revision 1.2 1997/08/04 10:24:20 mdw
* Sources placed under CVS control.
*
}
T( trace(TRACE_SETUP, "setup: canonify binary to `%s'", rq.cmd); )
- /* --- Run the check --- */
+ /* --- Run the check --- *
+ *
+ * If the user is already what she wants to be, then print a warning.
+ * Then, if I was just going to spawn a shell, quit, to reduce user
+ * confusion. Otherwise, do what was wanted anyway.
+ */
- {
+ if (rq.from == rq.to) {
+ moan("you already are `%s'!", to_pw->pw_name);
+ if (!cmd && todo == shell) {
+ moan("(to prevent confusion, I'm not spawning a shell)");
+ exit(0);
+ }
+ } else {
int a = check(&rq);
syslog(LOG_INFO,
puts("permission granted");
return (0);
} else {
- if (setuid(rq.to) == -1 || seteuid(rq.to) == -1)
+ if (setuid(rq.to) == -1)
die("couldn't set uid: %s", strerror(errno));
execve(rq.cmd, todo, env);
die("couldn't exec `%s': %s", rq.cmd, strerror(errno));