Fix mknod(...) with no file type bits
mknod(2) automatically defaults to S_IFREG if not given an explicit
file type, so pseudo should too. Otherwise, GNU tar can (for some
reason, it mostly does this when extracting xattrs?) invoke mknod
instead of open with O_CREAT to create a file, and just provide the
permission bits, and pseudo creates a "weird file" with no type bits
in the database, which is unhelpful.
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
Peter Seebach
8 years ago
|
0 |
2016-01-22:
|
|
1 |
* (seebs) Mask in S_IFREG when mknod called with no S_IFMT bits.
|
|
2 |
|
0 | 3 |
2015-09-22:
|
1 | 4 |
* (seebs) Fix modes after fopen/fopen64.
|
2 | 5 |
|
10 | 10 |
|
11 | 11 |
/* mask out mode bits appropriately */
|
12 | 12 |
mode = mode & ~pseudo_umask;
|
|
13 |
/* if you don't specify a type, assume regular file */
|
|
14 |
if (!(mode & S_IFMT)) {
|
|
15 |
mode |= S_IFREG;
|
|
16 |
}
|
|
17 |
pseudo_debug(PDBGF_FILE, "xmknodat creating '%s', mode 0%o\n",
|
|
18 |
path ? path : "<no name>", (int) mode);
|
13 | 19 |
|
14 | 20 |
/* we don't use underlying call, so _ver is irrelevant to us */
|
15 | 21 |
(void) ver;
|
11 | 11 |
|
12 | 12 |
/* mask out mode bits appropriately */
|
13 | 13 |
mode = mode & ~pseudo_umask;
|
|
14 |
/* if you don't specify a type, assume regular file */
|
|
15 |
if (!(mode & S_IFMT)) {
|
|
16 |
mode |= S_IFREG;
|
|
17 |
}
|
|
18 |
pseudo_debug(PDBGF_FILE, "mknodat creating '%s', mode 0%o\n",
|
|
19 |
path ? path : "<no name>", (int) mode);
|
14 | 20 |
|
15 | 21 |
#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
|
16 | 22 |
if (dirfd != AT_FDCWD) {
|
1066 | 1066 |
msg->uid = (uid_t) -1;
|
1067 | 1067 |
msg->gid = (gid_t) -1;
|
1068 | 1068 |
#endif
|
1069 | |
pseudo_debug(PDBGF_DB, "linking %s (uid -1 if xattr) for %s\n",
|
|
1069 |
pseudo_debug(PDBGF_DB | PDBGF_XATTR, "linking %s (uid -1 if xattr) for %s, mode 0%o\n",
|
1070 | 1070 |
msg->pathlen ? msg->path : "no path",
|
1071 | |
pseudo_op_name(msg->op));
|
|
1071 |
pseudo_op_name(msg->op),
|
|
1072 |
(int) msg->mode);
|
1072 | 1073 |
pdb_link_file(msg, &row);
|
1073 | 1074 |
}
|
1074 | 1075 |
if (pdb_set_xattr(row, oldpath, oldpathlen, xattr_flags)) {
|