From: Dreamcat Four Date: 2010-11-19T19:36:25+09:00 Subject: Re: Calling a bash script creates files as UID 501 ? Robert Klemme wrote in post #962523: > On 18.11.2010 18:32, John W Higgins wrote: > >> It does appear that the tarball maybe comes from OSX where 501 is a well >> known user id and therefore normally exists. I have CentOS boxes that appear >> to start at 501 and Gentoo boxes that appear to start at 1001 so it's just >> an oversight in the install script you are looking at but it's not something >> I would loose sleep over - and if you are inclined to do so then just run >> the chown command above. > > Granted, this can easily be fixed with chown. I'm not sure I understand > how this can produce the difference between > > system "/usr/local/rvm/src/rvm/scripts/install --prefix /usr/local/rvm/" > > and > > sudo /usr/local/rvm/src/rvm/scripts/install --prefix /usr/local/rvm/ > > when the script apparently also uses sudo. Do you have an explanation? > Hi Robert, Like John - I also haven't bothered to look into this properly and am just speculating now at this point. Since my original post, i've re-written my ruby script to do some fancy things. You can see it all in the same gist which has been heavily updated. Dropping the root permissions with: Process::sys.setgid(admin_group) Process::sys.setuid(Etc.getlogin) Solves the problem. Sudo is used sparingly to do 'level back up again' for any chgrp / chowning afterwards. The thing about this user 501 permissions - is that many of us have seen it happen before with the `tar` program. A tarball is created on the developer's computer. And for whatever reason when the files are unpacked on another computer they have the original permissions which were stored in the tarball. Perhaps the tar program differentiates between the root user, and a regular user. For example - a regular user cannot create new files with the UID 501 - its impossible because they dont have the privelidge. So in those cases tar must create the files assumed under the current users UID. Wheras if tar is invoked by a process UID=0 (the root user), then clearly tar will be allowed to create 501 UID owned files. > Kind regards > > robert -- Posted via http://www.ruby-forum.com/.