summaryrefslogtreecommitdiffstats
path: root/contrib/opie/opiesu.c
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-03-21 22:50:02 +0000
committermarkm <markm@FreeBSD.org>2002-03-21 22:50:02 +0000
commitda481742fe10db46be0a0f92255f012bcfa3a0a9 (patch)
tree5c9f598749274986230a9eaa1de3c9dd00eb09b3 /contrib/opie/opiesu.c
parent3b73ce2319e249cf2795cf4b0d0c624134f01e77 (diff)
parent4cdfa7814cda254acabe1040a2b2d0c4f5bc4295 (diff)
downloadFreeBSD-src-da481742fe10db46be0a0f92255f012bcfa3a0a9.zip
FreeBSD-src-da481742fe10db46be0a0f92255f012bcfa3a0a9.tar.gz
This commit was generated by cvs2svn to compensate for changes in r92906,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/opie/opiesu.c')
-rw-r--r--contrib/opie/opiesu.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/contrib/opie/opiesu.c b/contrib/opie/opiesu.c
index e2bbdb8..329679f 100644
--- a/contrib/opie/opiesu.c
+++ b/contrib/opie/opiesu.c
@@ -1,7 +1,7 @@
/* opiesu.c: main body of code for the su(1m) program
%%% portions-copyright-cmetz-96
-Portions of this software are Copyright 1996-1998 by Craig Metz, All Rights
+Portions of this software are Copyright 1996-1999 by Craig Metz, All Rights
Reserved. The Inner Net License Version 2 applies to these portions of
the software.
You should have received a copy of the license with this software. If
@@ -14,6 +14,8 @@ License Agreement applies to this software.
History:
+ Modified by cmetz for OPIE 2.4. Check euid on startup. Use
+ opiestrncpy().
Modified by cmetz for OPIE 2.32. Set up TERM and PATH correctly.
Modified by cmetz for OPIE 2.31. Fix sulog(). Replaced Getlogin() with
currentuser. Fixed fencepost error in month printed by sulog().
@@ -302,6 +304,7 @@ again:
argv++;
}
+
{
struct passwd *pwd;
char *p = getlogin();
@@ -314,14 +317,12 @@ again:
#endif /* HAVE_SULOG */
exit(1);
}
- strncpy(buf, pwd->pw_name, sizeof(buf)-1);
- buf[sizeof(buf)-1] = 0;
+ opiestrncpy(buf, pwd->pw_name, sizeof(buf));
if (!p)
p = "unknown";
- strncpy(currentuser, p, 31);
- currentuser[31] = 0;
+ opiestrncpy(currentuser, p, 31);
if (p && *p && strcmp(currentuser, buf)) {
strcat(currentuser, "(");
@@ -338,6 +339,15 @@ again:
exit(1);
}
+ if (geteuid()) {
+ syslog(LOG_CRIT, "'%s' failed for %s on %s: not running with superuser priveleges", argvbuf, currentuser, ttyname(2));
+#if HAVE_SULOG
+ sulog(0, NULL);
+#endif /* HAVE_SULOG */
+ fprintf(stderr, "You do not have permission to su %s\n", user);
+ exit(1);
+ };
+
/* Implement the BSD "wheel group" su restriction. */
#if DOWHEEL
/* Only allow those in group zero to su to root? */
OpenPOWER on IntegriCloud