Skip to content

Commit a8563d8

Browse files
committed
bin/xbps-create: record file mode, uid, and gid
1 parent 3054047 commit a8563d8

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

bin/xbps-create/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ struct xentry {
6666
char *file, *target;
6767
char sha256[XBPS_SHA256_SIZE];
6868
ino_t inode;
69+
uid_t uid;
70+
gid_t gid;
71+
mode_t mode;
6972
};
7073

7174
static TAILQ_HEAD(xentry_head, xentry) xentry_list =
@@ -396,6 +399,10 @@ ftw_cb(const char *fpath, const struct stat *sb, const struct dirent *dir UNUSED
396399
goto out;
397400
}
398401

402+
xe->uid = (sb->st_uid == geteuid()) ? 0 : sb->st_uid;
403+
xe->gid = (sb->st_gid == getegid()) ? 0 : sb->st_gid;
404+
xe->mode = sb->st_mode;
405+
399406
if (S_ISLNK(sb->st_mode)) {
400407
char buf[PATH_MAX];
401408
ssize_t len;
@@ -530,7 +537,6 @@ ftw_cb(const char *fpath, const struct stat *sb, const struct dirent *dir UNUSED
530537
xbps_dictionary_set_uint64(fileinfo, "inode", sb->st_ino);
531538
xe->inode = sb->st_ino;
532539
xe->size = (uint64_t)sb->st_size;
533-
534540
} else if (S_ISDIR(sb->st_mode)) {
535541
/* directory */
536542
xbps_dictionary_set_cstring_nocopy(fileinfo, "type", "dirs");
@@ -648,8 +654,10 @@ process_xentry(enum entry_type type, const char *mutable_files)
648654
xbps_dictionary_set_cstring(d, "target", xe->target);
649655
if (*xe->sha256)
650656
xbps_dictionary_set_cstring(d, "sha256", xe->sha256);
651-
if (xe->size)
652-
xbps_dictionary_set_uint64(d, "size", xe->size);
657+
xbps_dictionary_set_uint64(d, "size", xe->size);
658+
xbps_dictionary_set_uint32(d, "uid", xe->uid);
659+
xbps_dictionary_set_uint32(d, "gid", xe->gid);
660+
xbps_dictionary_set_uint32(d, "mode", xe->mode);
653661

654662
xbps_array_add(a, d);
655663
xbps_object_release(d);

0 commit comments

Comments
 (0)