diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
commit | cc8ed39b240180b58810784f844e253263594ac3 (patch) | |
tree | 15feebbb4be9a9168209609f48f0b100f9364420 /postprocess.c | |
download | busybox-cc8ed39b240180b58810784f844e253263594ac3.tar.gz |
Initial revision
Diffstat (limited to 'postprocess.c')
-rw-r--r-- | postprocess.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/postprocess.c b/postprocess.c new file mode 100644 index 000000000..bbc87e689 --- /dev/null +++ b/postprocess.c @@ -0,0 +1,41 @@ +#include "internal.h" + +extern int +post_process(const struct FileInfo * i) +{ + int status = 0; + + if ( i->destination == 0 || *i->destination == 0 ) + return 0; + + if ( status == 0 && i->changeMode ) { + mode_t mode = i->stat.st_mode & 07777; + mode &= i->andWithMode; + mode |= i->orWithMode; + status = chmod(i->destination, mode); + + if ( status != 0 && i->complainInPostProcess && !i->force ) { + name_and_error(i->destination); + return 1; + } + } + + if ( i->changeUserID || i->changeGroupID ) { + uid_t uid = i->stat.st_uid; + gid_t gid = i->stat.st_gid; + + if ( i->changeUserID ) + uid = i->userID; + if ( i->changeGroupID ) + gid = i->groupID; + + status = chown(i->destination, uid, gid); + + if ( status != 0 && i->complainInPostProcess && !i->force ) { + name_and_error(i->destination); + return 1; + } + } + + return status; +} |