chiark
/
gitweb
/
~mdw
/
become
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
15a3747
)
Do something useful when users attempt to become themselves.
author
mdw
<mdw>
Thu, 7 Aug 1997 16:28:59 +0000
(16:28 +0000)
committer
mdw
<mdw>
Thu, 7 Aug 1997 16:28:59 +0000
(16:28 +0000)
src/become.c
patch
|
blob
|
blame
|
history
diff --git
a/src/become.c
b/src/become.c
index 627eda56fb117938003bf0e9f02b202d26d374e9..a690072068fcd7da9653c7ea213e1b0477a41f2b 100644
(file)
--- a/
src/become.c
+++ b/
src/become.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-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'
*
*
* Main code for `become'
*
@@
-29,6
+29,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: become.c,v $
/*----- 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.
*
* Revision 1.2 1997/08/04 10:24:20 mdw
* Sources placed under CVS control.
*
@@
-708,9
+711,20
@@
int main(int argc, char *argv[])
}
T( trace(TRACE_SETUP, "setup: canonify binary to `%s'", rq.cmd); )
}
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,
int a = check(&rq);
syslog(LOG_INFO,
@@
-730,7
+744,7
@@
int main(int argc, char *argv[])
puts("permission granted");
return (0);
} else {
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));
die("couldn't set uid: %s", strerror(errno));
execve(rq.cmd, todo, env);
die("couldn't exec `%s': %s", rq.cmd, strerror(errno));