mirror of
https://codeberg.org/landley/toybox.git
synced 2026-01-26 06:07:55 +00:00
Fix "install -dm 02750 directory" and add tests.
This commit is contained in:
parent
896bb66a6d
commit
39dea7710f
@ -17,3 +17,10 @@ testing "install -D -t creates directory" \
|
||||
"touch a; install -Dt b a && echo yes" \
|
||||
"yes\n" "" ""
|
||||
rm -rf a b
|
||||
|
||||
testing "install -d" "umask 0 && install -d potato && stat -c%a potato" \
|
||||
"755\n" "" ""
|
||||
rmdir potato
|
||||
testcmd "-dm" "-dm 02750 potato && stat -c%a potato" "2750\n" "" ""
|
||||
rmdir potato
|
||||
testcmd '' '-dm +x potato && stat -c%a potato' '111\n' '' ''
|
||||
|
||||
@ -515,12 +515,15 @@ void install_main(void)
|
||||
TT.gid = TT.i.g ? xgetgid(TT.i.g) : -1;
|
||||
|
||||
if (FLAG(d)) {
|
||||
int mode = TT.i.m ? string_to_mode(TT.i.m, 0) : 0755;
|
||||
|
||||
for (ss = toys.optargs; *ss; ss++) {
|
||||
if (FLAG(v)) printf("%s\n", *ss);
|
||||
if (mkpathat(AT_FDCWD, *ss, 0777, MKPATHAT_MKLAST | MKPATHAT_MAKE))
|
||||
if (mkpathat(AT_FDCWD, *ss, mode, MKPATHAT_MKLAST | MKPATHAT_MAKE))
|
||||
perror_msg_raw(*ss);
|
||||
if (FLAG(g)||FLAG(o))
|
||||
if (lchown(*ss, TT.uid, TT.gid)) perror_msg("chown '%s'", *ss);
|
||||
if ((mode&~01777) && chmod(*ss, mode)) perror_msg("chmod '%s'", *ss);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user