WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to create dir with tc.staff ownership with extension startup  (Read 3336 times)

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
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...

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How to create dir with tc.staff ownership with extension startup
« Reply #1 on: June 29, 2010, 07: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


Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: How to create dir with tc.staff ownership with extension startup
« Reply #2 on: June 30, 2010, 08:30:15 PM »
Thanks, that helped me to a solution.

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: How to create dir with tc.staff ownership with extension startup
« Reply #3 on: July 03, 2010, 05: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".

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: How to create dir with tc.staff ownership with extension startup
« Reply #4 on: July 04, 2010, 01:44:57 AM »
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.

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: How to create dir with tc.staff ownership with extension startup
« Reply #5 on: July 04, 2010, 01:56:36 AM »
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.