projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(libfu_a_SOURCES): Add addext.c.
[gnulib.git]
/
lib
/
chown.c
diff --git
a/lib/chown.c
b/lib/chown.c
index
4e390a8
..
1d3346d
100644
(file)
--- a/
lib/chown.c
+++ b/
lib/chown.c
@@
-24,7
+24,7
@@
# include <unistd.h>
#endif
# include <unistd.h>
#endif
-/* FIXME. */
+/* FIXME
: describe
. */
int
chown (file, gid, uid)
int
chown (file, gid, uid)
@@
-34,8
+34,17
@@
chown (file, gid, uid)
{
if (gid == (gid_t) -1 || uid == (uid_t) -1)
{
{
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
}
#undef chown