Skip to main content
Added some information after trying Gilles answer.
Source Link
Vladimir T.
  • 51
  • 1
  • 1
  • 3

I am running Arch Linux on a Raspberry Pi 2.

I have a user-space program that uses Gordon's wiringPi library and, in particular, the piHiPri() function that attempts to set the highest priority for the current process (using sched_setscheduler and SCHED_RR mode). This function needs superuser privileges.

The root user is the default one when installing Arch Linux so I created a user named builder that I added to sudoers thanks to visudo.

My problem is: when I execute the program with the root user, the sched_setscheduler function returns “Operation not permitted” (getting it from errno).

If I execute it while being builder I get a “permission denied”.

However if I execute it with sudo myProgram while being builder, everything is fine and I can see that priority has changed with the top command.

I thought that the root user might not have UID 0 so I checked with id -u root but this returns 0.

ls -l myProgramm gives -rwxr-xr-x 1 root root. I also tried to set SUID with chmod +s myProgramm without success.

Any idea on how to make my program executable by root?

EDIT:

As Gilles advised I ran ulimit -r and it returned 0 in any cases (builderand root).

I changed a line in /etc/security/limits.conf from: * - rtprio 0

To : * - rtprio 99

This affected the output of ulimit -r as expected: it returns now 99.

I then tried again to run my program with root but I still have the same Operation not permitted error and now it does not work anymore with sudo (same Operation not permittedas above)... strange !

While investigating I reverted back to old /etc/security/limits.conf settings.

I am running Arch Linux on a Raspberry Pi 2.

I have a user-space program that uses Gordon's wiringPi library and, in particular, the piHiPri() function that attempts to set the highest priority for the current process (using sched_setscheduler and SCHED_RR mode). This function needs superuser privileges.

The root user is the default one when installing Arch Linux so I created a user named builder that I added to sudoers thanks to visudo.

My problem is: when I execute the program with the root user, the sched_setscheduler function returns “Operation not permitted” (getting it from errno).

If I execute it while being builder I get a “permission denied”.

However if I execute it with sudo myProgram while being builder, everything is fine and I can see that priority has changed with the top command.

I thought that the root user might not have UID 0 so I checked with id -u root but this returns 0.

ls -l myProgramm gives -rwxr-xr-x 1 root root. I also tried to set SUID with chmod +s myProgramm without success.

Any idea on how to make my program executable by root?

I am running Arch Linux on a Raspberry Pi 2.

I have a user-space program that uses Gordon's wiringPi library and, in particular, the piHiPri() function that attempts to set the highest priority for the current process (using sched_setscheduler and SCHED_RR mode). This function needs superuser privileges.

The root user is the default one when installing Arch Linux so I created a user named builder that I added to sudoers thanks to visudo.

My problem is: when I execute the program with the root user, the sched_setscheduler function returns “Operation not permitted” (getting it from errno).

If I execute it while being builder I get a “permission denied”.

However if I execute it with sudo myProgram while being builder, everything is fine and I can see that priority has changed with the top command.

I thought that the root user might not have UID 0 so I checked with id -u root but this returns 0.

ls -l myProgramm gives -rwxr-xr-x 1 root root. I also tried to set SUID with chmod +s myProgramm without success.

Any idea on how to make my program executable by root?

EDIT:

As Gilles advised I ran ulimit -r and it returned 0 in any cases (builderand root).

I changed a line in /etc/security/limits.conf from: * - rtprio 0

To : * - rtprio 99

This affected the output of ulimit -r as expected: it returns now 99.

I then tried again to run my program with root but I still have the same Operation not permitted error and now it does not work anymore with sudo (same Operation not permittedas above)... strange !

While investigating I reverted back to old /etc/security/limits.conf settings.

deleted 16 characters in body; edited tags
Source Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

I am running ArchLinuxArch Linux on a Raspberry Pi 2.

I have a user-space program that uses Gordon's wiringPi library and, in particular, the piHiPri() functionpiHiPri() function that attempts to set the highest priority for the current process (using sched_setschedulersched_setscheduler and SCHED_RRSCHED_RR mode).

This function This function needs Super-User priviledgessuperuser privileges.

Root The root user is the default one when installing ArchLinuxArch Linux so I created a user named builderbuilder that I added to sudoerssudoers thanks to visudo.

My problem My problem is:

When when I execute the program with the rootroot user, the sched_setschedulersched_setscheduler function returns Operation not permitted“Operation not permitted” (getting it from errnoerrno).

If I execute it while being builderbuilder I get a permission denied“permission denied”.

However if I execute it with sudo myProgram while being builderbuilder, everything is fine and I can see that priority has changed with the top command.

I thought that the rootroot user might not have UID 0 so I checked with id -u root but this returns 0.

ls -l myProgramm gives -rwxr-xr-x 1 root root. I also tried to set SUID with chmod +s myProgramm without success.

Any idea on how to make my program executable by rootroot?

Thanks !

I am running ArchLinux on a Raspberry Pi 2.

I have a user-space program that uses Gordon's wiringPi library and, in particular, the piHiPri() function that attempts to set the highest priority for the current process (using sched_setscheduler and SCHED_RR mode).

This function needs Super-User priviledges.

Root user is the default one when installing ArchLinux so I created a user named builder that I added to sudoers thanks to visudo.

My problem is:

When I execute the program with root user the sched_setscheduler function returns Operation not permitted (getting it from errno).

If I execute it while being builder I get a permission denied.

However if I execute it with sudo myProgram while being builder everything is fine and I can see that priority has changed with top command.

I thought that root user might not have UID 0 so I checked with id -u root but this returns 0.

ls -l myProgramm gives -rwxr-xr-x 1 root root. I also tried to set SUID with chmod +s myProgramm without success.

Any idea on how to make my program executable by root?

Thanks !

I am running Arch Linux on a Raspberry Pi 2.

I have a user-space program that uses Gordon's wiringPi library and, in particular, the piHiPri() function that attempts to set the highest priority for the current process (using sched_setscheduler and SCHED_RR mode). This function needs superuser privileges.

The root user is the default one when installing Arch Linux so I created a user named builder that I added to sudoers thanks to visudo.

My problem is: when I execute the program with the root user, the sched_setscheduler function returns “Operation not permitted” (getting it from errno).

If I execute it while being builder I get a “permission denied”.

However if I execute it with sudo myProgram while being builder, everything is fine and I can see that priority has changed with the top command.

I thought that the root user might not have UID 0 so I checked with id -u root but this returns 0.

ls -l myProgramm gives -rwxr-xr-x 1 root root. I also tried to set SUID with chmod +s myProgramm without success.

Any idea on how to make my program executable by root?

Source Link
Vladimir T.
  • 51
  • 1
  • 1
  • 3

Why sudo user can use sched_setscheduler SCHED_RR while root can not?

I am running ArchLinux on a Raspberry Pi 2.

I have a user-space program that uses Gordon's wiringPi library and, in particular, the piHiPri() function that attempts to set the highest priority for the current process (using sched_setscheduler and SCHED_RR mode).

This function needs Super-User priviledges.

Root user is the default one when installing ArchLinux so I created a user named builder that I added to sudoers thanks to visudo.

My problem is:

When I execute the program with root user the sched_setscheduler function returns Operation not permitted (getting it from errno).

If I execute it while being builder I get a permission denied.

However if I execute it with sudo myProgram while being builder everything is fine and I can see that priority has changed with top command.

I thought that root user might not have UID 0 so I checked with id -u root but this returns 0.

ls -l myProgramm gives -rwxr-xr-x 1 root root. I also tried to set SUID with chmod +s myProgramm without success.

Any idea on how to make my program executable by root?

Thanks !