I will try your suggestion "su -c command -l username" and test for some more days.





在2014年08月03 17时15分,"Erik Petrich"<epetrich@ivorytower.norman.ok.us>写道:



On Sun, 3 Aug 2014, Ben Shi wrote:

> Erik,
>
> Thanks for your suggestion.
>
> Actually my board will reboot and recover to its original sdcard image
> each 2-3 days automatically, so any potential security threats might not
> be a problem.
>
> The real problem is I have to start the auto build script in
> /etc/init.d/rc.local (or other rc* ?). Since there is no user logging
> in, the ~ is treated as / rather than /root, and all works are done
> under /.
>
>
>
> Well I still worry that, for my board's quick recovery. But my concern
> is can the way copying .ssh/ from /root to / or creating a symbolic link
> to /root/.ssh in/ work?
>
> Do you have more suggestions?

If you could install the cron daemon, it should be able to run a command
as an arbitrary user.

Otherwise, you could use su to temporarily log in as an arbitrary user and
run some command:

  su -c "command" -l username

Just replace the "command" (keep the quotes if you need spaces) and
username with whatever you need. Assuming you are logged in as root
already, it shouldn't stop to ask for a password and so would be
scriptable.

  Erik


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
sdcc-devel mailing list
sdcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-devel