chown: fix ownership format string
authorMurphy Zhou <jencce.kernel@gmail.com>
Mon, 25 Apr 2022 08:20:51 +0000 (16:20 +0800)
committerZorro Lang <zlang@kernel.org>
Tue, 26 Apr 2022 18:54:00 +0000 (02:54 +0800)
After coreutils rebasing to 9.1, chown(1) behavior changes:
"
   chown and chroot now warn about usages like "chown root.root f",
   which have the nonstandard and long-obsolete "." separator that
   causes problems on platforms where user names contain ".".
   Applications should use ":" instead of ".".
"

https://lwn.net/Articles/891574/

With this behavior change, old format of ownership string will cause
warning like this:
"
+chown: warning: '.' should be ':': '1000.1000'
+.chown: warning: '.' should be ':': '1100.1100'
+.chown: warning: '.' should be ':': '1200.1200'
+.chown: warning: '.' should be ':': '1300.1300'
+.chown: warning: '.' should be ':': '1400.1400'
"

The new format works fine with old versions of coreutils.

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Reviewed-by: Zorro Lang <zlang@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/dump
tests/generic/099
tests/generic/237
tests/generic/318
tests/generic/380
tests/generic/597
tests/generic/598

index 6de7dab48913bcf1c7680696a9133553d60484a7..0dcc9655d328345a1789a4757657752282e5e480 100644 (file)
@@ -517,7 +517,7 @@ _do_create_dumpdir_fill()
            fi
        fi
        if [ -n "$owner" -a -n "$group" ]; then
-           chown $owner.$group $file
+           chown $owner:$group $file
        fi
        if [ -n "$perms" ]; then
            chmod $perms $file
@@ -676,10 +676,10 @@ _do_create_dump_symlinks()
        fi
 
        if [ -n "$owner" -a -n "$group" ]; then
-           chown $owner.$group $file
+           chown $owner:$group $file
        fi
        if [ -n "$owner" -a -n "$group" ]; then
-           chown -h $owner.$group $file-link
+           chown -h $owner:$group $file-link
        fi
        if [ -n "$perms" ]; then
            chmod $perms $file
index 6ba04dd8b271067ee3f92d0634d7dbeedc539f11..5cdac9abc42a8908cae06ff2b3039707be25d9f7 100755 (executable)
@@ -74,7 +74,7 @@ EOF
 chmod u=rwx file1
 chmod g=rw- file1
 chmod o=r-- file1
-chown $acl1.$acl2 file1
+chown $acl1:$acl2 file1
 _acl_ls file1
 
 echo ""
@@ -264,7 +264,7 @@ do
        touch a/$i/mumble
 done
 popd >/dev/null
-chown -R 12345.54321 root
+chown -R 12345:54321 root
 echo "Change #1..."
 _runas -u 12345 -g 54321 -- chacl -r u::rwx,g::-w-,o::--x root
 find root -print | sort | xargs chacl -l
index 93eafd8470ec526b0972ef1e927a0084472aae41..f17e32e47c3258e82a079a3720c74635959440fa 100755 (executable)
@@ -38,7 +38,7 @@ mkdir $seq.dir1
 cd $seq.dir1
 
 touch file1
-chown $acl1.$acl1 file1
+chown $acl1:$acl1 file1
 
 echo "Expect to FAIL"
 _runas -u $acl2 -g $acl2 -- setfacl -m u::rwx file1 2>&1 | sed 's/^setfacl: \/.*file1: Operation not permitted$/setfacl: file1: Operation not permitted/'
index 5edc9f35f03df6f7a6e84c21c6820c241c48a7a2..ed50818ab2b30ba1dc451e49d8ea5ad3ad360fd7 100755 (executable)
@@ -72,7 +72,7 @@ _scratch_mkfs       >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 touch $file
-chown $acl1.$acl1 $file
+chown $acl1:$acl1 $file
 
 # set acls from init_user_ns, to be checked from inside the userns
 setfacl -n -m u:$acl2:rw,g:$acl2:r $file
index 4993dad00eae62ef2164cbe7418cc482d933aeaf..21b789dd2b73566241add1be0f8f7185ae50f38b 100755 (executable)
@@ -35,7 +35,7 @@ _chowning_file()
        let count=$start
        while (( count < limit )); do
            touch $file
-           chown $count.$count $file
+           chown $count:$count $file
            echo -n "."
            let count=count+delta
        done
index aa93237ee7658eed335da732fd0bf09545a740ce..ff985ca61915107bd6740bb9c81d5e1940cd4a52 100755 (executable)
@@ -46,8 +46,8 @@ HARDLINK_PROTECTION=`sysctl -n fs.protected_hardlinks`
 test_symlink()
 {
        ln -s $TEST_DIR/$seq/target $TEST_DIR/$seq/sticky_dir/symlink
-       chown $OTHER.$OTHER $TEST_DIR/$seq/sticky_dir
-       chown $OWNER.$OWNER $TEST_DIR/$seq/sticky_dir/symlink
+       chown $OTHER:$OTHER $TEST_DIR/$seq/sticky_dir
+       chown $OWNER:$OWNER $TEST_DIR/$seq/sticky_dir/symlink
        # If we can read the target, we followed the link
        _user_do "cat $TEST_DIR/$seq/sticky_dir/symlink" | _filter_test_dir
        rm -f $TEST_DIR/$seq/sticky_dir/symlink
@@ -55,7 +55,7 @@ test_symlink()
 
 test_hardlink()
 {
-       chown $OWNER.$OWNER $TEST_DIR/$seq/target
+       chown $OWNER:$OWNER $TEST_DIR/$seq/target
        chmod go-rw $TEST_DIR/$seq/target
        _user_do "ln $TEST_DIR/$seq/target $TEST_DIR/$seq/sticky_dir/hardlink" \
                | _filter_test_dir
index 160e6d4bc1feeba90ad8d9e5ab6b73620d36d631..769c1b1a1ad94b7e9a6e9943b1553d5efc0e4207 100755 (executable)
@@ -64,16 +64,16 @@ setup_tree()
        mkdir -p $TEST_DIR/$seq
        mkdir -p $TEST_DIR/$seq/sticky_dir
        chmod 1777 $TEST_DIR/$seq/sticky_dir
-       chown $USER2.$USER2 $TEST_DIR/$seq/sticky_dir
+       chown $USER2:$USER2 $TEST_DIR/$seq/sticky_dir
 
        # Create file & fifo in that dir owned by $USER1, and open
        # normal read/write privs for world & group
        $XFS_IO_PROG -c "open -f $TEST_DIR/$seq/sticky_dir/file"
-       chown $USER1.$USER1 $TEST_DIR/$seq/sticky_dir/file
+       chown $USER1:$USER1 $TEST_DIR/$seq/sticky_dir/file
        chmod o+rw $TEST_DIR/$seq/sticky_dir/file
 
        mkfifo $TEST_DIR/$seq/sticky_dir/fifo
-       chown $USER1.$USER1 $TEST_DIR/$seq/sticky_dir/fifo
+       chown $USER1:$USER1 $TEST_DIR/$seq/sticky_dir/fifo
        chmod o+rw $TEST_DIR/$seq/sticky_dir/fifo
 }