WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: how to achieve tc uid=1000 rather than uid=1001  (Read 3276 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
how to achieve tc uid=1000 rather than uid=1001
« on: July 28, 2019, 10:19:45 PM »
I have a partition with some personal files that various UNIX-like OSs need to access. All files in the partition have user:group ownership of 1000:1000.

My tc user is having permissions problems because its uid is 1001 and gid is 50. Is there a way to tell TC to use uid 1000 for user tc?

I already changed this line in /etc/init.d/tc-config:

Code: [Select]
        /usr/sbin/adduser -s /bin/sh -G staff -D "$USER"
to
Code: [Select]
        /usr/sbin/adduser -u 1000 -s /bin/sh -G staff -D "$USER"
and re-made core.gz, but even with the modified core.gz my tc user still ends up with uid=1001 for some reason.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #1 on: July 28, 2019, 10:39:24 PM »
Oops, I just noticed that the addUser function in /etc/init.d/tc-config is only called if booting with user=foo where foo is other than tc. I also noticed that the /etc/passwd file in core.gz already has an entry for tc.

Therefore, I solved my problem by changing this line in /etc/passwd
Code: [Select]
tc:x:1001:50:Linux User,,,:/home/tc:/bin/sh
to this
Code: [Select]
tc:x:1000:50:Linux User,,,:/home/tc:/bin/sh
Solved  :)

P.S. If you need to modify your core.gz for some reason, here are the steps I used:
Code: [Select]
# mkdir /tmp/dest
# cd /tmp/dest
# gunzip -c /path/to/core.gz | cpio -i
-> change /tmp/dest contents
# cd /tmp/dest
# find . | cpio -H newc -o | gzip -9 > ../core.gz-new

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #2 on: July 28, 2019, 10:47:43 PM »
Hi GNUser
You could have also run:
Code: [Select]
sudo /usr/sbin/adduser -u 1000 -s /bin/sh -G staff -D GNUserafter booting. Then logout and login as GNUser.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #3 on: July 28, 2019, 10:54:19 PM »
Thanks, Rich. That's a nice alternative I hadn't thought of.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #4 on: July 28, 2019, 11:04:59 PM »
Hi GNUser
Yup, lots of ways to skin a cat problem in linux:
Code: [Select]
sudo chown 1001:1001 *Access your files, then:
Code: [Select]
sudo chown 1000:1000 *

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #5 on: July 29, 2019, 08:27:02 AM »
You could have also run:
Code: [Select]
sudo /usr/sbin/adduser -u 1000 -s /bin/sh -G staff -D GNUserafter booting. Then logout and login as GNUser.

I like this solution the best, as I want to avoid having to modify core.gz and want to avoid having to remember to change permissions before and after accessing the files.

Is there a way to automate the above (i.e., after booting, automatically run the command then automatically logout tc and login GNUser)?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #6 on: July 29, 2019, 10:34:21 AM »
Hi GNUser
Add the following to your  /opt/.filetool.lst  file:
Code: [Select]
etc/group
etc/gshadow
etc/passwd
etc/shadow
etc/sudoers
Run the  adduser  command and then run a backup. User  GNUser  will now be persistent.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #7 on: July 29, 2019, 02:29:56 PM »
Wow, cool :o

Thank you, Richard. Indeed, there are so many ways to solve a problem using *nix tools... It's an embarrassment of riches.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
Re: how to achieve tc uid=1000 rather than uid=1001
« Reply #8 on: August 09, 2019, 05:56:52 PM »
Today I discovered, quite by accident, that simply using user=gnuser boot code is enough: user gnuser is created with uid=1000. No need to manually create the user or backup any files. Thank you, Robert Shingledecker :)