LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2019, 09:29 AM   #1
Michael65589
LQ Newbie
 
Registered: Oct 2019
Posts: 3

Rep: Reputation: Disabled
Capabilities CAP_NET_ADMIN for using system call


Hello,
I want to use a systemcall (ip link set can0 up) in my c-programm that have no root privileges. Therefor I set the capabilities to CAP_NET_RAW and CAP_NET_ADMIN.
But I always get a permission error message. When I set the capabilities to the ip program it works.
How can I get my program working without touching the capabilities of ip program?

Thanks
 
Old 10-21-2019, 10:54 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,160

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
Instead of calling the ip program, set the link up by calling the ioctl directly. On ethernet you would call the SIOCSIFFLAGS ioctl with ifr_flags = IFF_UP. Not sure on can bus.
 
Old 10-21-2019, 11:29 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
That's what sudo is good for.
 
Old 10-23-2019, 02:40 AM   #4
Michael65589
LQ Newbie
 
Registered: Oct 2019
Posts: 3

Original Poster
Rep: Reputation: Disabled
I solved my problem by using netlink communikation for configuration. Furthermore I set the capabilities to CAP_NET_RAW and CAP_NET_ADMIN.

So I can execute my application with user privileges.

I also tried to use a system call in my application to ip link .... and use setuid for my applicaton but without success.

I set the user and group for my application to root, then setuid and setgid. Call my application as user show a permission denied issue when the application do the system call.
 
  


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
may i know details about system call how to use system call and definition for virtua mahi rajee Programming 1 05-02-2012 07:45 AM
how to write a system call which returns current system time using call by reference mukul2kul4 Debian 2 09-25-2011 11:17 PM
How to use write system call within a system call byteinnovator Linux - Kernel 18 08-05-2010 07:13 AM
calling a system call inside a system call suresh.j Linux - Kernel 1 08-03-2010 09:28 PM
Calling a system call from a system call? Loc_8 Programming 0 09-16-2006 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:37 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