WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] Help with root powered tce-load...LOW priority  (Read 3338 times)

aus9

  • Guest
[SOLVED] Help with root powered tce-load...LOW priority
« on: September 14, 2016, 10:10:42 PM »
Hi

If anyone gets a chance, I try to build as root for various reasons but my coding skills are failing me to understand why I can no longer use this code.

Code: [Select]
USER=`cat /etc/sysconfig/tcuser`
BUILD="compiletc submitqc  "
for Z in $BUILD
    do
    su -c "tce-load -i $Z" $USER
done

I am pretty sure it used to work in the past but now it gives me message for each package in the list to not run as root.
I have for each package, ensured I have already downloaded it, and I have kept the list short otherwise I would use one line.

cheers
« Last Edit: September 16, 2016, 08:46:43 AM by Rich »

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Help with root powered tce-load...LOW priority
« Reply #1 on: September 14, 2016, 11:52:06 PM »
Hi aus9

Why would you load as root?   Also am not sure the user is necessary either.

I'm pretty sure this would work fine
Code: [Select]
tce-load -i compiletc submitqc

Or if there's many extensions to be loaded you could use
Code: [Select]
BUILD="compiletc submitqc etc etc"
for Z in $BUILD
do
    tce-load -i $Z
done

iirc we used to launch submitqc with root privileges, but that may have been fixed..?
:)



« Last Edit: September 14, 2016, 11:54:28 PM by coreplayer2 »

aus9

  • Guest
Re: Help with root powered tce-load...LOW priority
« Reply #2 on: September 15, 2016, 01:36:33 AM »
Hi

I use root as it automatically gives me
Root:root ownership so the $user was to allow me to
Run tce-load and wget as local usrr.

If it is no longer possible I will change.. Still hoping others might know
Cheers

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Help with root powered tce-load...LOW priority
« Reply #3 on: September 15, 2016, 03:41:43 AM »
True,  tce-load  refuses to load extensions as root.
You can run  tce-load  as  tcuser  via either
Code: [Select]
su -c "tce-load -i $Z" - "$USER"
(note the additional  - )
or
Code: [Select]
su "$USER" -c "tce-load -i $Z"
Download a copy and keep it handy: Core book ;)

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Help with root powered tce-load...LOW priority
« Reply #4 on: September 15, 2016, 03:58:36 AM »
Hi aus9

I'm not sure it's wise to start work on a project in root which is designed to be run as user.  Having said that, the command
Code: [Select]
su -c "tce-load -i compiletc" tc
works fine if you are root to begin with. 
This command assumes you are root already to pass "tce-load -i xxx" to the shell as $user.     However, in your script the user is most likely tc as it is read from tcuser not root as expected.

So I suggest you were not root when attempting to run this script??

You have to consider why you need to be root overcomplicating a quite simple task???   But if I can't change your mind then at least I've given the reason why your script is not working..

:)



« Last Edit: September 15, 2016, 04:05:58 AM by coreplayer2 »

aus9

  • Guest
Re: Help with root powered tce-load...LOW priority
« Reply #5 on: September 16, 2016, 12:54:11 AM »
I went to country area for a few days and took a dodgy electrical system laptop and a working Android phone.

What I did not take was my brains or glasses. On return I ran a script I had at the home PC and it worked. Upon looking with my glasses on I had typo in my USER bit.   :-[  :-[

I hope you have a good laugh at me as I deserve it. We need humour in this world so I hope I provide better jokes in the future.

Mods
if you have time feel free to mark as solved

Thanks coreplayer2 and Misalf and I hope in the fullness of time you may forgive me for wasting your time.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Help with root powered tce-load...LOW priority
« Reply #6 on: September 16, 2016, 03:54:59 AM »
No problem, no time wasted. Also, this might help others to load extensions from bootlocal.sh etc.
Download a copy and keep it handy: Core book ;)

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Help with root powered tce-load...LOW priority
« Reply #7 on: September 16, 2016, 06:11:13 AM »
I use this code in scripts to load piCore extensions.
Code: [Select]
sudo -u tc tce-load -i usbutils.tczBetter/worst/different?

aus9

  • Guest
Re: [SOLVED] Help with root powered tce-load...LOW priority
« Reply #8 on: September 16, 2016, 09:26:46 AM »
Hi Greg

In my OP, I should clarified that I tend to make a build script for TCZ submissions rather than a compile script that makes the package but does not show the building dependencies or other stuff. In other words, I am not doing something just as root but for some other reason. I was deliberately being vague as I was not asking for help to build a package. Well not at this stage, I am sure I will need help ;)

if you are using sudo, your script is run as a local user with root powers.

I open a terminal and get full root then run the script as root.

The differences I think are that in the creating extension wiki, someone (not me) wrote
Quote
Try to use sudo in scripts as least as possible

but you can find plenty of dev team members with compile scripts that run as local user.

sooner or later, they have to do some things with root powers such as the tce.installed script
and root ownership of some dir or files.

by running as root I achieve those things more easily but can not run tce-load or wget as root.
Hence the various tce-load options offered here.
« Last Edit: September 16, 2016, 09:32:33 AM by aus9 »

aus9

  • Guest
Re: [SOLVED] Help with root powered tce-load...LOW priority
« Reply #9 on: September 16, 2016, 07:39:18 PM »
Hi

mods, if others who post agree, delete this entire thread.