[nycbug-talk] anyone know why install functions this way?

Matthew Story matt at tablethotels.com
Fri Dec 9 20:08:31 EST 2011


Know this isn't a bug list or anything like that, but figured I'd throw this out there ... the only thing I found on the interweb was regarding RPMs on CentOS ... so this is apparently not even a BSDism, but it makes writing my installer scripts vastly less reliable.  Lots more below, but the gist is this:

install -o root -d foo/

Will create the directory with my user and effective group id, and my umask ... and yield an error message ... but still exit 0 (success).  At the very least I would expect the directory to linger with these permissions and exit non-zero (failure) ... this is also not consistant with the behavior of files.

Anyway ... anyone know a historical reason for this, or have a good hack around this ... getting patches into section 1 to trickle down into my world takes a while, assuming the behavior is even a bug ...

------------------------lots of copy-paste below----------------------------------

[matt ~]$ mkdir install-showcase
[matt ~]$ cd install-showcase/
[matt ~/install-showcase]$ who am i
matt             14       Dec  9 19:52 
[matt ~/install-showcase]$ install -d ./test.dir; echo $? # install a directory as me, success!
0
[matt ~/install-showcase]$ ls -d ./test.dir; echo $? # see, success!
./test.dir
0
[matt ~/install-showcase]$ install -o root -d ./test.dir.1; echo $? # install a directory as root, success?!                                                                   
install: chown 0:4294967295 ./test.dir.1: Operation not permitted
0
[matt ~/install-showcase]$ ls -d ./test.dir.1 # see, success!
./test.dir.1
[matt ~/install-showcase]$ ls -d ./test.dir.1; echo $? # see, success!                                                                                                         
./test.dir.1
0
[matt ~/install-showcase]$ install -o doesnotexist -d ./test.dir.2; echo $? # install directory as a user that doesn't exist, failure!
install: doesnotexist: Invalid argument
67
[matt ~/install-showcase]$ touch filetobeinstalled; ls filetobeinstalled; echo $? # but does it work with files?                                                               
filetobeinstalled
0
[matt ~/install-showcase]$ install filetobeinstalled test.file; echo $? # install a file as me, success!                                                                       
0
[matt ~/install-showcase]$ ls filetobeinstalled; echo $?
filetobeinstalled
0
[matt ~/install-showcase]$ install -o root filetobeinstalled test.file.1; echo $? # install a file as root, success?                                                           
install: test.file.1: chown/chgrp: Operation not permitted
71
[matt ~/install-showcase]$ ls test.file.1; echo $? # not even a lingering file                                                                                                 
ls: test.file.1: No such file or directory
1
[matt ~/install-showcase]$ install -S -o root -d test.dir.2; echo $? # how about a directory in safe mode?                                                                     
install: chown 0:4294967295 test.dir.2: Operation not permitted
0
[matt ~/install-showcase]$ ls -d test.dir.2; echo $? # yup ... safe mode too ... :(
test.dir.2
0
[matt ~/install-showcase]$ install -S -o root -d test.dir.2; echo $? # how about a directory in safe mode ... with an existing target
install: chown 0:4294967295 test.dir.2: Operation not permitted
0
[matt ~/install-showcase]$ ls -ld test.dir.2; echo $? # yup ... safe mode too ... :(
drwxr-xr-x  2 matt  matt  2 Dec  9 20:00 test.dir.2
0
[matt ~/install-showcase]$ install -S -o root -d test.dir.2; echo $? # how about a directory in safe mode ... with an existing target
install: chown 0:4294967295 test.dir.2: Operation not permitted
0


More information about the talk mailing list