Tiny Core Linux

General TC => Programming & Scripting - Unofficial => Topic started by: jur on June 29, 2010, 04:32:01 PM

Title: How to create dir with tc.staff ownership with extension startup
Post by: jur on June 29, 2010, 04:32:01 PM
Sorry for this question... it comes from being a linux newbie...

I am creating an extension and with a startup script want to conditionally create a dir under $HOME/.config. But the one that is created has root:staff ownership. How would I create one with tc:staff owner while being root? I have looked around but not found an answer...
Title: Re: How to create dir with tc.staff ownership with extension startup
Post by: gerald_clark on June 29, 2010, 04:54:20 PM
A user can cannot create files owned by another user.
Root will have to temporarily change to user tc with the su command.
EX: su -c 'touch junk' tc
Or ( as root ) change the owner.
EX: touch junk ; chown tc.staff junk

Title: Re: How to create dir with tc.staff ownership with extension startup
Post by: jur on June 30, 2010, 05:30:15 PM
Thanks, that helped me to a solution.
Title: Re: How to create dir with tc.staff ownership with extension startup
Post by: SvOlli on July 03, 2010, 02:31:21 PM
jur, keep in mind that there are users that use the "user=xxx" command line parameter to switch to a user different from "tc". You'll need to use the environment variable "$USER" instead of a hard-coded "tc".
Title: Re: How to create dir with tc.staff ownership with extension startup
Post by: jur on July 03, 2010, 10:44:57 PM
Yes I realise that; I did actually try that in the 1st round and found $USER to be root.  :P So I haven't got it going fully generic yet.
Title: Re: How to create dir with tc.staff ownership with extension startup
Post by: SvOlli on July 03, 2010, 10:56:36 PM
Hmmm... that's a bit strange, since USER gets set in /etc/init.d/tc-config. Didn't dig deep enough before the last post. ;)

Anyway, as an alternative you can read the user from /etc/sysconfig/tcuser.