From 1ab0c59c605bdf2cb75edf743f78e5317796b355 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 13 Mar 1997 05:16:47 +0000 Subject: [PATCH] . --- lib/Makefile.in | 34 +++++++++++++++++----------------- lib/chown.c | 13 +++++++++++-- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib/Makefile.in b/lib/Makefile.in index 407f53ab9..3ba5ee0cf 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -49,7 +49,7 @@ RM = @RM@ noinst_LIBRARIES = libfu.a -EXTRA_DIST = mkdir.c rmdir.c getline.c mktime.c strftime.c getgroups.c +EXTRA_DIST = chown.c mkdir.c rmdir.c getline.c mktime.c strftime.c getgroups.c INCLUDES = -I.. -I$(srcdir) -I../intl @@ -92,13 +92,13 @@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) LINK = $(CC) $(LDFLAGS) -o $@ HEADERS = $(noinst_HEADERS) -DIST_COMMON = Makefile.am Makefile.in alloca.c basename.c error.c \ -error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \ -getdate.c getgroups.c getline.c group-member.c interlock memcmp.c \ -memcpy.c memset.c mkdir.c mktime.c mountlist.c obstack.c obstack.h \ -posixtm.c regex.c regex.h rename.c rmdir.c rpmatch.c rx.c rx.h stpcpy.c \ -strcasecmp.c strdup.c strftime.c strndup.c strstr.c strtol.c strtoul.c \ -ylwrap +DIST_COMMON = Makefile.am Makefile.in alloca.c basename.c chown.c \ +error.c error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c \ +ftruncate.c getdate.c getgroups.c getline.c group-member.c interlock \ +memcmp.c memcpy.c memset.c mkdir.c mktime.c mountlist.c obstack.c \ +obstack.h posixtm.c regex.c regex.h rename.c rmdir.c rpmatch.c rx.c \ +rx.h stpcpy.c strcasecmp.c strdup.c strftime.c strndup.c strstr.c \ +strtol.c strtoul.c ylwrap PACKAGE = @PACKAGE@ @@ -109,15 +109,15 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) \ TAR = tar DEP_FILES = .deps/alloca.P .deps/argmatch.P .deps/backupfile.P \ -.deps/basename.P .deps/dirname.P .deps/error.P .deps/euidaccess.P \ -.deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P .deps/fsusage.P \ -.deps/ftruncate.P .deps/full-write.P .deps/getdate.P .deps/getgroups.P \ -.deps/getline.P .deps/getopt.P .deps/getopt1.P .deps/getversion.P \ -.deps/group-member.P .deps/idcache.P .deps/isdir.P .deps/long-options.P \ -.deps/makepath.P .deps/memcmp.P .deps/memcpy.P .deps/memset.P \ -.deps/mkdir.P .deps/mktime.P .deps/modechange.P .deps/mountlist.P \ -.deps/obstack.P .deps/path-concat.P .deps/posixtm.P .deps/regex.P \ -.deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/rx.P \ +.deps/basename.P .deps/chown.P .deps/dirname.P .deps/error.P \ +.deps/euidaccess.P .deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P \ +.deps/fsusage.P .deps/ftruncate.P .deps/full-write.P .deps/getdate.P \ +.deps/getgroups.P .deps/getline.P .deps/getopt.P .deps/getopt1.P \ +.deps/getversion.P .deps/group-member.P .deps/idcache.P .deps/isdir.P \ +.deps/long-options.P .deps/makepath.P .deps/memcmp.P .deps/memcpy.P \ +.deps/memset.P .deps/mkdir.P .deps/mktime.P .deps/modechange.P \ +.deps/mountlist.P .deps/obstack.P .deps/path-concat.P .deps/posixtm.P \ +.deps/regex.P .deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/rx.P \ .deps/safe-read.P .deps/save-cwd.P .deps/savedir.P .deps/stpcpy.P \ .deps/strcasecmp.P .deps/strdup.P .deps/strftime.P .deps/stripslash.P \ .deps/strndup.P .deps/strstr.P .deps/strtol.P .deps/strtoul.P \ diff --git a/lib/chown.c b/lib/chown.c index 2d3b4e821..1d3346d36 100644 --- a/lib/chown.c +++ b/lib/chown.c @@ -34,8 +34,17 @@ chown (file, gid, uid) { if (gid == (gid_t) -1 || uid == (uid_t) -1) { - /* Stat file to get id(s) that will remain unchanged. */ - FIXME + struct stat file_stats; + + /* Stat file to get id(s) that should remain unchanged. */ + if (stat (file, &file_stats)) + return 1; + + if (gid == (gid_t) -1) + gid = file_stats.st_gid; + + if (uid == (uid_t) -1) + uid = file_stats.st_uid; } #undef chown -- 2.11.0