blob: bbc87e689be0561cbeb14a520a91d7185e58d933 [file] [log] [blame]
Eric Andersencc8ed391999-10-05 16:24:54 +00001#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}