WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Multi-user TCL: errors in Wiki instructions  (Read 4318 times)

Offline DanielH

  • Newbie
  • *
  • Posts: 36
Multi-user TCL: errors in Wiki instructions
« on: March 31, 2013, 09:18:12 PM »
Dear "tinycorers".

I' ve found some errors in TCL Wiki, page TinyCore Passwords (http://wiki.tinycorelinux.net/wiki:passwd):

1) I've added users, groups, and add passwords for tc, root and new users.

2) Following these instructions in wiki, I've edited shutdown.sh and bootsync.sh for persistent opt:

.......
Save Passwords using Persistent opt

If you use persistent opt, open the terminal and type

sudo cp /etc/shadow /opt/shadow

Add the following to /opt/bootsync.sh

sudo mv /etc/shadow /etc/shadow_old
sudo cp /opt/shadow /etc/shadow

Note that this will apply group staff and mode g+w to /opt/shadow on each boot, as it's the case with every file in /opt.
........

Editing:
1)
My shutdown.sh:

#!/bin/busybox ash
. /etc/init.d/tc-functions
useBusybox
# put user shutdown commands here
# saving users, groups and passwords...
sudo cp /etc/passwd /opt/passwd
sudo cp /etc/shadow /opt/shadow
sudo cp /etc/group /opt/group
sudo cp /etc/gshadow /opt/gshadow
# If no backup of home was done then loop through valid users to clean up.
if [ ! -e /tmp/backup_done ] || ! grep -q "^home" /opt/.filetool.lst; then
  awk 'BEGIN { FS=":" }  $3 >= 1000 && $1 != "nobody" { print $1 }' /etc/passwd > /tmp/users
  while read U; do
    while read F; do
      TARGET="/home/${U}/$F"
      if [ -d "$TARGET" ]; then
        rm -rf "$TARGET"
      else
        if [ -f "$TARGET" ]; then
          rm -f "$TARGET"
        fi
      fi
    done < /opt/.xfiletool.lst     
  done < /tmp/users
fi

2)
My bootsync.sh following wiki procedures (IT FAILS!!!):

#!/bin/sh
# put other system startup commands here, the boot process will wait until they complete.
# Use bootlocal.sh for system startup commands that can run in the background
# and therefore not slow down the boot process.
/usr/bin/sethostname TCL
# recovering users, groups and passwords...
sudo mv /etc/passwd /etc/passwd_old
sudo cp /opt/passwd /etc/passwd
sudo mv /etc/shadow /etc/shadow_old
sudo cp /opt/shadow /etc/shadow
sudo mv /etc/group /etc/group_old
sudo cp /opt/group /etc/group
sudo mv /etc/gshadow /etc/gshadow_old
sudo cp /opt/gshadow /etc/gshadow
/opt/bootlocal.sh &

3)
Rebooting:

Near the end of boot messages (no quiet bootcode):
..................
..................

sudo: unknown uid: 0
sudo: unknown uid: 0
sudo: unknown uid: 0
sudo: unknown uid: 0
sudo: unknown uid: 0
sudo: unknown uid: 0
sudo: unknown uid: 0
sudo: unknown uid: 0

One message for each sudo command in bootsync.sh. ?????
Evidently, at this stage, root privileges for sudo are not set yet (may be are set later in boot process? When?).

.................

After this, in sh login screen, no users other than tc or root are recognized, nor saved passwords are allowed.
Therefore, if there is a "noautologin" bootcode in extlinux.conf, nor tc nor root can not login in system.
BTW: I don't know if tc and root have a public initial password in TCL (CD, PPR).

passwd, shadow, group and gshadow files in /etc directory remains as in base system.
But passwd, shadow, group and gshadow files in /mnt/sda1/opt directory are OK!

....................................................................

FIXING CODE FOR A MULTI-USER TCL:

My new bootsync.sh:

#!/bin/sh
# put other system startup commands here, the boot process will wait until they complete.
# Use bootlocal.sh for system startup commands that can run in the background
# and therefore not slow down the boot process.
/usr/bin/sethostname TCL
# recovering users, groups and passwords...
/bin/mv /etc/passwd /etc/passwd_old
/bin/cp /opt/passwd /etc/passwd
/bin/mv /etc/shadow /etc/shadow_old
/bin/cp /opt/shadow /etc/shadow
/bin/mv /etc/group /etc/group_old
/bin/cp /opt/group /etc/group
/bin/mv /etc/gshadow /etc/gshadow_old
/bin/cp /opt/gshadow /etc/gshadow
/opt/bootlocal.sh &

OK!!! IT WORKS!!!
SOLVED!!!

IMHO, editing the wiki page is absolutely necessary.
Wrong instructions can result in serious errors, and new users may consider TCL as unreliable system...

Best regards,
DanielH

P.S.: I apologize for my bad english...

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: Multi-user TCL: errors in Wiki instructions
« Reply #1 on: March 31, 2013, 10:00:03 PM »
Hi DanielH
Quote
passwd, shadow, group and gshadow files in /etc directory remains as in base system.
Why not add those file to  /.opt/filetool.lst  and let Tinycores backup/restore functions deal with it?

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Multi-user TCL: errors in Wiki instructions
« Reply #2 on: March 31, 2013, 10:03:46 PM »
One message for each sudo command in bootsync.sh. ?????
Evidently, at this stage, root privileges for sudo are not set yet (may be are set later in boot process? When?).

That sounds a bit the wrong way round, rather at this stage non-privileged users do not yet come into play.

Try and remove all instances of "sudo" and see what happens then.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Multi-user TCL: errors in Wiki instructions
« Reply #3 on: March 31, 2013, 10:12:05 PM »
In linked wikipage, the term "sudo" is mentioned only in reference to stage of non-privileged user being logged in.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline DanielH

  • Newbie
  • *
  • Posts: 36
Re: Multi-user TCL: errors in Wiki instructions
« Reply #4 on: April 01, 2013, 09:52:30 AM »
Dear "tinycorers":

The problem is SOLVED, please read near the bottom of my previous post:

Quote:
"
FIXING CODE FOR A MULTI-USER TCL:

My new bootsync.sh:

#!/bin/sh
# put other system startup commands here, the boot process will wait until they complete.
# Use bootlocal.sh for system startup commands that can run in the background
# and therefore not slow down the boot process.
/usr/bin/sethostname TCL
# recovering users, groups and passwords...
/bin/mv /etc/passwd /etc/passwd_old
/bin/cp /opt/passwd /etc/passwd
/bin/mv /etc/shadow /etc/shadow_old
/bin/cp /opt/shadow /etc/shadow
/bin/mv /etc/group /etc/group_old
/bin/cp /opt/group /etc/group
/bin/mv /etc/gshadow /etc/gshadow_old
/bin/cp /opt/gshadow /etc/gshadow
/opt/bootlocal.sh &

OK!!! IT WORKS!!!
SOLVED!!!
"

@Rich:
I'm working in PPR mode, TCL installed in HDD with tce=sda1 opt=sda1 home=sda1 and norestore bootcodes.
¿Why edit /opt/.filetool.lst? If filetool will be used, it will slow the boot process due the time required to decompress functions and passwd, shadow, group, gshadow files  (I'm working in a Pentium MMX 64 MB RAM 4 GB HDD). I think that move and copy processes are faster than filetool decompressing.

@tinypoodle:
1) In my previous post, I had already shown my fixed bootsync.sh, I've replaced all "sudo" commands by /bin/"commad name" (read at the beginning of this post, please), it works very well!!
2) At boot time there is not privileged or non-privileged users. The bootsync.sh must to recover all necessary files that system will use to login process!!!
3) In wiki page, sudo commands are referred to "Saving passwords using Persistent opt"... "Add the following to /opt/bootsync.sh" item...

I insist: IMHO, editing "Saving passwords using Persistent opt" in wiki page is absolutely necessary.
Wrong instructions can result in serious errors, and new users may consider TCL as unreliable system...

Best regards,
DanielH

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: Multi-user TCL: errors in Wiki instructions
« Reply #5 on: April 01, 2013, 10:10:23 AM »
Hi DanielH
I'm quite aware of your machines limitations. I run the same processor with 256Mbytes of RAM as a file server. I doubt
you would notice any difference time wise if the only things listed in your .filetool.lst file were those four files, but I
could be wrong.
Quote
I think that move and copy processes are faster ...
Unless you are using the  _old  files for something, I think  cp -f  may be faster yet.

Offline DanielH

  • Newbie
  • *
  • Posts: 36
Re: Multi-user TCL: errors in Wiki instructions
« Reply #6 on: April 01, 2013, 11:40:36 AM »
Thanks you, Rich!
I did not remember cp -f (force option).
I'll try and post results...

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Multi-user TCL: errors in Wiki instructions
« Reply #7 on: April 01, 2013, 08:02:26 PM »
¿Why edit /opt/.filetool.lst?

Because it is the default mechanism of the system and the cleanest solution to restore files.

Quote
If filetool will be used, it will slow the boot process due the time required to decompress functions and passwd, shadow, group, gshadow files  (I'm working in a Pentium MMX 64 MB RAM 4 GB HDD). I think that move and copy processes are faster than filetool decompressing.

I wouldn't bet my money on that assumption. You would have to provide timings to convince...

Quote
@At boot time there is not privileged or non-privileged users.

That is what I meant to say.

Quote
In wiki page, sudo commands are referred to "Saving passwords using Persistent opt"... "Add the following to /opt/bootsync.sh" item...

Mea culpa, I overlooked that, you are right there.

Quote
I insist: IMHO, editing "Saving passwords using Persistent opt" in wiki page is absolutely necessary.
Wrong instructions can result in serious errors, and new users may consider TCL as unreliable system...

Wiki consists from user contributed content. Your forum login serves as well as wiki login.
Hic Rhodus, hic salta!  ;)
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Multi-user TCL: errors in Wiki instructions
« Reply #8 on: April 01, 2013, 09:39:36 PM »
Code: [Select]
root@box:/home/tc# mkdir /mnt/sda1/tmp/ && time tar czf /mnt/sda1/tmp/test.tgz -C / etc/group etc/gshadow etc/passwd etc/shadow   
real    0m 0.01s
user    0m 0.00s
sys     0m 0.00s
root@box:/home/tc# mkdir /tmp/test/ && time tar xf /mnt/sda1/tmp/test.tgz -C /tmp/test
real    0m 0.01s
user    0m 0.00s
sys     0m 0.00s
root@box:/home/tc# time cp /etc/group /etc/gshadow /etc/passwd /etc/shadow /mnt/sda1/tmp/
real    0m 0.02s
user    0m 0.00s
sys     0m 0.00s
root@box:/home/tc# rm /mnt/sda1/tmp/test.tgz && time cp /mnt/sda1/tmp/* /tmp/test/
real    0m 0.01s
user    0m 0.00s
sys     0m 0.00s

Though this was measured with a P IV @1600Mhz, I don't think significantly enough - if any - could be gained with a Pentium MMX by substituting tar with cp.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline DanielH

  • Newbie
  • *
  • Posts: 36
Re: Multi-user TCL: errors in Wiki instructions
« Reply #9 on: April 02, 2013, 12:38:43 PM »
TEST:

root@TCLonP1mmx64mbRAM:~# mkdir /mnt/sda1/tmp/ && time tar czf /mnt/sda1/tmp/test.tgz -C / etc/group etc/gshadow etc/passwd etc/shadow
real    0m 0.07s
user    0m 0.03s
sys     0m 0.03s
root@TCLonP1mmx64mbRAM:~# mkdir /tmp/test/ && time tar xf /mnt/sda1/tmp/test.tgz -C /tmp/test
real    0m 0.04s
user    0m 0.01s
sys     0m 0.02s
root@TCLonP1mmx64mbRAM:~# time cp /etc/group /etc/gshadow /etc/passwd /etc/shadow /mnt/sda1/tmp/
real    0m 0.02s
user    0m 0.00s
sys     0m 0.01s
root@TCLonP1mmx64mbRAM:~# rm /mnt/sda1/tmp/test.tgz && time cp /mnt/sda1/tmp/* /tmp/test/
real    0m 0.02s
user    0m 0.00s
sys     0m 0.01s

tinypoodle: give your money, please...  ;-D  (It's a joke, of course; difference is insignificant, I will continue to learn).

About wiki edit: I didn't knew that wiki has the same login than forum. Thanks you.
I wish to edit the wiki's page, but my english is too bad (brutish english)...
Hic Rhodus, but I fear I will fall on the sea!!!  :-D

Rich: you're right.
Removed all rm (unnecesary) codes. Replaced cp codes by cp -f . Thanks you.

Best regards,
DanielH