WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: ondemand logic  (Read 5006 times)

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
ondemand logic
« on: August 17, 2021, 08:49:35 AM »
Hi all,

I am developing a suite to customize a TC USB/ISO disk [1], At the moment I put every tcz in a folder named tcz and I load it at startup.

However I wish to use the standard tce folder but I have one problem in using optionals / onboot.list.

I put all tcz in tce/optional then I put in ondemand.lst the package with its dependecies. Then I do:

tc@box:~$ sudo unlock.sh
/mnt/sda1 (RW)
/mnt/sda2 (RW)

tc@box:~$ sudo ondemand wget.tcz

tc@box:~$ wget
BusyBox v1.33.0 (2021-01-17 14:57:11 UTC) multi-call binary.

tc@box:~$ /usr/local/bin/wget
-ash: /usr/local/bin/wget: not found

tc@box:~$ ondemand -e wget.tcz
tc@box:~$ wget: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

tc@box:~$ sudo ondemand libssl.so.1.1.tcz

tc@box:~$ ondemand -e wget.tcz
tc@box:~$ wget: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

The library is still missing. How I can manage the load of executable and its dependencies? Thank you, R.


[1] https://github.com/robang74/tinycore-editor

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: ondemand logic
« Reply #1 on: August 17, 2021, 09:19:19 AM »
Why not use tce-load?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: ondemand logic
« Reply #2 on: August 17, 2021, 09:36:56 AM »
That looks like your dir is missing the .dep files.
The only barriers that can stop you are the ones you create yourself.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 799
Re: ondemand logic
« Reply #3 on: August 17, 2021, 12:47:57 PM »
... How I can manage the load of executable and its dependencies? Thank you, R.
The logic of recursively build the dependencies of dependencies, is in the script /usr/bin/tce-load, at subroutine/function recursive_scan_dep(), called with parameter "$TARGETSFETCH", etc. It is written in awk language.

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: ondemand logic
« Reply #4 on: August 17, 2021, 11:42:21 PM »
Thank you Juanito, nick65go and curaga.

Just another question: why tce-load does not fall-back to tc.staff when executed by root?

Offline nick65go

  • Hero Member
  • *****
  • Posts: 799
Re: ondemand logic
« Reply #5 on: August 18, 2021, 02:56:02 AM »
Just another question: why tce-load does not fall-back to tc.staff when executed by root?
IMHO: it can be easy done; but why are you so sure that $USER = tc ?
 On booting you can choose to create a user (default is tc), but if you choose user = roberto (lets say!) then the user "tc" does not exist in this tinycore system.

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: ondemand logic
« Reply #6 on: August 18, 2021, 06:04:07 AM »
Just another question: why tce-load does not fall-back to tc.staff when executed by root?
IMHO: it can be easy done; but why are you so sure that $USER = tc ?

It is irrelevant the name of the user. $SUDO_USER might help or not but the uid=1001 remains the same

In attachment the code, I cannot post here because a forum bug about config error.
« Last Edit: August 18, 2021, 06:06:53 AM by Roberto A. Foglietta »

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: ondemand logic
« Reply #7 on: August 18, 2021, 06:48:19 AM »
In attachment an example of tce-load working as root falling back to uid=1001 user.

You can test making an ISO with the last version of TinyCore Editor (suite)

https://github.com/robang74/tinycore-editor
« Last Edit: August 18, 2021, 07:02:11 AM by Roberto A. Foglietta »

Offline nick65go

  • Hero Member
  • *****
  • Posts: 799
Re: ondemand logic
« Reply #8 on: August 18, 2021, 07:55:53 AM »
nice catch, so you run (as root) your new function getuser ( ) , from file / etc / init.d / tc-functions, to change on the fly the tc user string from / etc / passwd :)   
So basically the same "user ID", not another user, aha!

PS: i get many internal server errors when I try to post, so i must use space between  "/" and "(" <-- maybe a server bug
« Last Edit: August 18, 2021, 08:01:08 AM by nick65go »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: ondemand logic
« Reply #9 on: August 18, 2021, 07:58:05 AM »
Hi Roberto A. Foglietta
... Just another question: why tce-load does not fall-back to tc.staff when executed by root?
Because it doesn't need to. It aborts if you try to run it as root:
Code: [Select]
tc@box:~$ sudo tce-load
Don't run this as root.

It is irrelevant the name of the user. $SUDO_USER might help or not but the uid=1001 remains the same ...
Really? I'm pretty sure user  tc  with  uid=1001  is built into the base system. If you select another user, that user
gets assigned their own  uid.

Since the  tce  directory is a shared resource amongst all users, I would say  read/write  permission for  staff  is
what's important since all users should belong to that group.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 799
Re: ondemand logic
« Reply #10 on: August 18, 2021, 08:15:22 AM »
why not short-hand it as:
Code: [Select]
[ uuid == 0 ] && USER=`sed...`

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: ondemand logic
« Reply #11 on: August 18, 2021, 08:41:43 AM »

It is irrelevant the name of the user. $SUDO_USER might help or not but the uid=1001 remains the same ...
Really? I'm pretty sure user  tc  with  uid=1001  is built into the base system. If you select another user, that user
gets assigned their own  uid.

Since the  tce  directory is a shared resource amongst all users, I would say  read/write  permission for  staff  is
what's important since all users should belong to that group.

So, the most important thing is to use an user that belong to the staff group, is it right?
It does not matter that it matches with the current user as long as belong to staff.
Because all users should belong to staff group, is it right?

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: ondemand logic
« Reply #12 on: August 18, 2021, 08:53:50 AM »
Hi Roberto A. Foglietta
... It does not matter that it matches with the current user as long as belong to staff.
Because all users should belong to staff group, is it right?
That would be my understanding of it. If you look at the  addUser  function in  /etc/init.d/tc-config  it sets the group
to  staff  for every user added. So if I add user  Rich  to my system, I'll still be able to load extensions installed
by user  tc.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 799
Re: ondemand logic
« Reply #13 on: August 18, 2021, 11:28:15 AM »
I wonder if a solution will be like this: start tce-load (as root user, by mistake), and the first instruction inside it will check for $user=root, and in this case just "re-lunch it" aka
Code: [Select]
sudo -u tc -exec ($@). So basically all remaining instructions are ignored and it starts again as user tc.

PS: I do not know the implication for cache /memory.
« Last Edit: August 18, 2021, 11:38:48 AM by nick65go »

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: ondemand logic
« Reply #14 on: August 18, 2021, 11:49:14 AM »
Hi Roberto A. Foglietta
... It does not matter that it matches with the current user as long as belong to staff.
Because all users should belong to staff group, is it right?
That would be my understanding of it. If you look at the  addUser  function in  /etc/init.d/tc-config  it sets the group
to  staff  for every user added. So if I add user  Rich  to my system, I'll still be able to load extensions installed
by user  tc.

So, my patch seems working, as far as we know.
Who we need to involve to evaluate to integrate my changes?
Thank, -R