summaryrefslogtreecommitdiff
path: root/usr/src/cmd/print/bsd-sysv-commands/lp.c
diff options
context:
space:
mode:
authorRalph Turner - Sun UK - Contractor <Ralph.Turner@Sun.COM>2010-05-27 10:20:25 +0100
committerRalph Turner - Sun UK - Contractor <Ralph.Turner@Sun.COM>2010-05-27 10:20:25 +0100
commit05f9a513b6ce84a1c8ebdc256737b1e8bd5ea049 (patch)
treeb90d0e33754ac5579670ccba7fc6f75dd1e9b2e4 /usr/src/cmd/print/bsd-sysv-commands/lp.c
parent05b58617e776d05dc8fc4d3d4966d9a05ebf1da0 (diff)
downloadillumos-joyent-05f9a513b6ce84a1c8ebdc256737b1e8bd5ea049.tar.gz
6925888 printer job submitted via suid program
Diffstat (limited to 'usr/src/cmd/print/bsd-sysv-commands/lp.c')
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/lp.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr/src/cmd/print/bsd-sysv-commands/lp.c b/usr/src/cmd/print/bsd-sysv-commands/lp.c
index 5c8b877ca4..46ef3cf665 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/lp.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/lp.c
@@ -34,7 +34,9 @@
#include <libintl.h>
#include <papi.h>
#include "common.h"
-
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
#ifdef HAVE_LIBMAGIC /* for mimetype auto-detection */
#include <magic.h>
#endif /* HAVE_LIBMAGIC */
@@ -77,10 +79,18 @@ main(int ac, char *av[])
int validate = 0;
int modify = -1;
int c;
+ uid_t ruid;
+ struct passwd *pw;
(void) setlocale(LC_ALL, "");
(void) textdomain("SUNW_OST_OSCMD");
+ ruid = getuid();
+ if ((pw = getpwuid(ruid)) != NULL)
+ (void) initgroups(pw->pw_name, pw->pw_gid);
+ (void) setuid(ruid);
+
+
while ((c = getopt(ac, av, "DEH:P:S:T:cd:f:i:mn:o:pq:rst:Vwy:")) != EOF)
switch (c) {
case 'H': /* handling */