checkpath: apply ownership to all paths given on command line

The stat structure was not being initialized correctly in do_check. This
was causing the owner adjustment to be skipped if the first path had the
correct owner.

Also, the "correcting owner" message should always be printed when the
owner is being changed.

X-Gentoo-Bug: 518042
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=518042
This commit is contained in:
William Hubbs 2014-07-28 10:41:24 -05:00
parent 275714bdc7
commit 2624a8c8a7

View File

@ -67,6 +67,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
int r;
int u;
memset(&st, 0, sizeof(st));
if (stat(path, &st) || trunc) {
if (type == inode_file) {
einfo("%s: creating file", path);
@ -140,8 +141,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
if (st.st_dev || st.st_ino)
einfo("%s: correcting owner", path);
einfo("%s: correcting owner", path);
if (chown(path, uid, gid)) {
eerror("%s: chown: %s", applet, strerror(errno));
return -1;