LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-20-2019, 04:27 AM   #1
mail2manig86
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, 04:40 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,359
Blog Entries: 3

Rep: Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767
Welcome.

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

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

Code:
%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.
 
  


Reply



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 01:09 PM
[SOLVED] sudo and non sudo in one command Garrett85 Linux - Newbie 11 08-16-2015 04: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 03:48 PM
sudo non-user/non-root password Alex_Dc Linux - Security 3 02-19-2010 06: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 07:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:43 PM.

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