1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/*
* static int
* wrap_lchown(const char *path, uid_t owner, gid_t group) {
*/
pseudo_msg_t *msg;
struct stat64 buf;
if (!path) {
errno = EFAULT;
return -1;
}
pseudo_debug(2, "lchown(%s, %d, %d)\n",
path ? path : "<nil>", owner, group);
if (real___lxstat64(_STAT_VER, path, &buf) == -1) {
return -1;
}
if (owner == -1 || group == -1) {
msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf);
/* copy in any existing values... */
if (msg) {
if (msg->result == RESULT_SUCCEED) {
pseudo_stat_msg(&buf, msg);
} else {
pseudo_debug(2, "lchown to %d:%d on %s, ino %llu, new file.\n",
owner, group, path,
(unsigned long long) buf.st_ino);
}
} else {
pseudo_diag("stat within lchown of '%s' [%llu] failed.\n",
path, (unsigned long long) buf.st_ino);
}
}
if (owner != -1) {
buf.st_uid = owner;
}
if (group != -1) {
buf.st_gid = group;
}
msg = pseudo_client_op(OP_CHOWN, -1, -1, path, &buf);
if (!msg) {
errno = ENOSYS;
rc = -1;
} else if (msg->result != RESULT_SUCCEED) {
errno = msg->xerrno;
rc = -1;
} else {
rc = 0;
}
/* return rc;
* }
*/
|