- for(c=2; c<argc; c++) {
- stat(argv[c], &stbuf);
- if(chown(argv[c], stbuf.st_uid, gid) < 0) {
+ pwd = getpwuid(uid);
+ if (pwd == NULL) {
+ fprintf(stderr, "Who are you?\n");
+ exit(2);
+ }
+ if (uid && pwd->pw_gid != gid) {
+ for (i=0; gr->gr_mem[i]; i++)
+ if (!(strcmp(pwd->pw_name, gr->gr_mem[i])))
+ goto ok;
+ fprintf(stderr, "You are not a member of the %s group.\n",
+ argv[0]);
+ exit(2);
+ }
+ok:
+ for (c = 1; c < argc; c++) {
+ if (stat(argv[c], &stbuf)) {