X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/8dbf4a5bc15ce570d15ceb695f952481af2bb6ef..31cef89cb428866f787983e68246030321893df4:/usr/src/cmd/newgrp.c diff --git a/usr/src/cmd/newgrp.c b/usr/src/cmd/newgrp.c index af49a5e827..8cd048f9e2 100644 --- a/usr/src/cmd/newgrp.c +++ b/usr/src/cmd/newgrp.c @@ -1,3 +1,4 @@ +static char *sccsid = "@(#)newgrp.c 4.1 (Berkeley) 10/1/80"; #include #include #include @@ -13,43 +14,38 @@ char **argv; register i; if(argc != 2) { printf("usage: newgrp groupname\n"); - done(); + exit(13); } if((grp=getgrnam(argv[1])) == NULL) { printf("%s: no such group\n", argv[1]); - done(); + exit(13); } if((pwd=getpwuid(getuid())) == NULL) { printf("You do not exist!\n"); - done(); + exit(13); } for(i=0;grp->gr_mem[i];i++) if(strcmp(grp->gr_mem[i], pwd->pw_name) == 0) break; if(grp->gr_mem[i] == 0 && strcmp(grp->gr_name,"other")) { printf("Sorry\n"); - done(); + exit(13); } if(grp->gr_passwd[0] != '\0' && pwd->pw_passwd[0] == '\0') { if(strcmp(grp->gr_passwd, crypt(getpass("Password:"),grp->gr_passwd)) != 0) { printf("Sorry\n"); - done(); + exit(13); } } - if(setgid(grp->gr_gid) < 0) + if(setgid(grp->gr_gid) < 0) { perror("setgid"); - done(); -} - -done() -{ - register i; - + exit(13); + } setuid(getuid()); for (i=3; i<15; i++) close(i); - execl("/bin/sh", "sh", 0); + execl((pwd->pw_shell[0]?pwd->pw_shell:"/bin/sh"), "-i", 0); printf("No shell!\n"); exit(0); }