Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 02-20-2019, 05:27 AM   #1
LQ Newbie
Registered: Feb 2019
Posts: 1

Rep: Reputation: Disabled
Not able to use sudo command in System calls using non root user

I have to run my process as a non root user.
This process needs to call for some system calls.

Example system("udhcpc -ieth0")

The above example works well when my process started with root user

If I changed my process start with non root user. This system calls fails because it needs root permission to start.

So I gave sudo in the system call. But it fails.
I have also tried to use execl instead of system call. But I am seeing the same issue

The following error occurs
"sudo: unable to change to root gid: Operation not permitted"
"sudo: unable to initialize policy plugin"
Old 02-20-2019, 05:40 AM   #2
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,097
Blog Entries: 3

Rep: Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666Reputation: 3666

sudo needs to be configured for each specific combination of command + account. So to run udhcpc from the account 'foobar' append the following to /etc/sudoers using the program visudo

%foobar ALL=(root:root) /sbin/udhcpc -i eth0

%foobar ALL=(root:root) NOPASSWD:/sbin/udhcpc -i eth0
Mind the spacing in either case and be sure to use the correct path for udhcpc.

For background see Michael W Lucas' talk "sudo: You're Doing It Wrong", which has a video and slides available. It is long but thorough.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sudo to user other than root but do not allow sudo to root Westmoreland Linux - Security 4 07-13-2022 02:09 PM
[SOLVED] sudo and non sudo in one command Garrett85 Linux - Newbie 11 08-16-2015 05:40 PM
Question about the sudo command, specifically how to have sudo act as if user is root slacker_ Linux - Newbie 17 09-22-2013 04:48 PM
sudo non-user/non-root password Alex_Dc Linux - Security 3 02-19-2010 07:28 PM
Can't use sudo, only account that's not root is not a sudo'ers [Ubuntu 9.10] randyriver10 Linux - Desktop 1 01-09-2010 08:56 PM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 03:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration