summaryrefslogtreecommitdiff
path: root/postprocess.c
diff options
context:
space:
mode:
Diffstat (limited to 'postprocess.c')
-rw-r--r--postprocess.c41
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 @@
1#include "internal.h"
2
3extern int
4post_process(const struct FileInfo * i)
5{
6 int status = 0;
7
8 if ( i->destination == 0 || *i->destination == 0 )
9 return 0;
10
11 if ( status == 0 && i->changeMode ) {
12 mode_t mode = i->stat.st_mode & 07777;
13 mode &= i->andWithMode;
14 mode |= i->orWithMode;
15 status = chmod(i->destination, mode);
16
17 if ( status != 0 && i->complainInPostProcess && !i->force ) {
18 name_and_error(i->destination);
19 return 1;
20 }
21 }
22
23 if ( i->changeUserID || i->changeGroupID ) {
24 uid_t uid = i->stat.st_uid;
25 gid_t gid = i->stat.st_gid;
26
27 if ( i->changeUserID )
28 uid = i->userID;
29 if ( i->changeGroupID )
30 gid = i->groupID;
31
32 status = chown(i->destination, uid, gid);
33
34 if ( status != 0 && i->complainInPostProcess && !i->force ) {
35 name_and_error(i->destination);
36 return 1;
37 }
38 }
39
40 return status;
41}