projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
=/^G show total bytes now; document may not always work
[unix-history]
/
usr
/
src
/
usr.sbin
/
chown
/
chgrp.c
diff --git
a/usr/src/usr.sbin/chown/chgrp.c
b/usr/src/usr.sbin/chown/chgrp.c
index
0093da5
..
f33d495
100644
(file)
--- a/
usr/src/usr.sbin/chown/chgrp.c
+++ b/
usr/src/usr.sbin/chown/chgrp.c
@@
-5,7
+5,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)chgrp.c 5.
4
(Berkeley) %G%";
+static char sccsid[] = "@(#)chgrp.c 5.
9
(Berkeley) %G%";
#endif not lint
/*
#endif not lint
/*
@@
-84,20
+84,20
@@
main(argc, argv)
ok:
for (c = 1; c < argc; c++) {
/* do stat for directory arguments */
ok:
for (c = 1; c < argc; c++) {
/* do stat for directory arguments */
- if (stat(argv[c], &stbuf)) {
- status +=
error("can't access %s",
argv[c]);
+ if (
l
stat(argv[c], &stbuf)) {
+ status +=
Perror(
argv[c]);
continue;
}
if (uid && uid != stbuf.st_uid) {
status += error("You are not the owner of %s", argv[c]);
continue;
}
continue;
}
if (uid && uid != stbuf.st_uid) {
status += error("You are not the owner of %s", argv[c]);
continue;
}
- if (rflag &&
stbuf.st_mode & S_IFDIR
) {
- status += chownr(argv[c]
, stbuf.st_uid, gid
);
+ if (rflag &&
((stbuf.st_mode & S_IFMT) == S_IFDIR)
) {
+ status += chownr(argv[c]);
continue;
}
continue;
}
- if (chown(argv[c],
stbuf.st_uid
, gid)) {
- status +=
error("can't change %s",
argv[c]);
+ if (chown(argv[c],
-1
, gid)) {
+ status +=
Perror(
argv[c]);
continue;
}
}
continue;
}
}
@@
-115,12
+115,12
@@
isnumber(s)
return (1);
}
return (1);
}
-chownr(dir
, uid, gid
)
+chownr(dir)
char *dir;
{
register DIR *dirp;
register struct direct *dp;
char *dir;
{
register DIR *dirp;
register struct direct *dp;
-
register
struct stat st;
+ struct stat st;
char savedir[1024];
int ecode;
char savedir[1024];
int ecode;
@@
-129,18
+129,22
@@
chownr(dir, uid, gid)
/*
* Change what we are given before doing its contents.
*/
/*
* Change what we are given before doing its contents.
*/
- if (chown(dir,
uid, gid) < 0 && error("can't change %s",
dir))
+ if (chown(dir,
-1, gid) < 0 && Perror(
dir))
return (1);
return (1);
- if (chdir(dir) < 0)
- return (Perror(dir));
- if ((dirp = opendir(".")) == NULL)
- return (Perror(dir));
+ if (chdir(dir) < 0) {
+ Perror(dir);
+ return (1);
+ }
+ if ((dirp = opendir(".")) == NULL) {
+ Perror(dir);
+ return (1);
+ }
dp = readdir(dirp);
dp = readdir(dirp); /* read "." and ".." */
ecode = 0;
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
dp = readdir(dirp);
dp = readdir(dirp); /* read "." and ".." */
ecode = 0;
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
- if (stat(dp->d_name, &st) < 0) {
- ecode =
error("can't access %s",
dp->d_name);
+ if (
l
stat(dp->d_name, &st) < 0) {
+ ecode =
Perror(
dp->d_name);
if (ecode)
break;
continue;
if (ecode)
break;
continue;
@@
-150,14
+154,14
@@
chownr(dir, uid, gid)
dp->d_name);
continue;
}
dp->d_name);
continue;
}
- if (
st.st_mode&
S_IFDIR) {
- ecode = chownr(dp->d_name
, st.st_uid, gid
);
+ if (
(st.st_mode & S_IFMT) ==
S_IFDIR) {
+ ecode = chownr(dp->d_name);
if (ecode)
break;
continue;
}
if (ecode)
break;
continue;
}
- if (chown(dp->d_name,
st.st_uid
, gid) < 0 &&
- (ecode =
error("can't change %s",
dp->d_name)))
+ if (chown(dp->d_name,
-1
, gid) < 0 &&
+ (ecode =
Perror(
dp->d_name)))
break;
}
closedir(dirp);
break;
}
closedir(dirp);
@@
-192,7
+196,9
@@
Perror(s)
char *s;
{
char *s;
{
- fprintf(stderr, "chgrp: ");
- perror(s);
- return (1);
+ if (!fflag) {
+ fprintf(stderr, "chgrp: ");
+ perror(s);
+ }
+ return (!fflag);
}
}