I want write a c program.And a common user(not in root group) will run this program. In this program,I call fread(/dev/sdc...) and fwrite(/dev/sdc),but this call will return "permission no allow".If I use the root user,will be ok. How to change to the authority to root's?
I know the root's password.
On Tue, 2 Dec 2008 17:20:43 +0800 "wk" 304702903@qq.com wrote:
I want write a c program.And a common user(not in root group) will run this program. In this program,I call fread(/dev/sdc...) and fwrite(/dev/sdc),but this call will return "permission no allow".
Why do you work with the devices? Can't you just operate on the directories where those drives are mounted?
And if you absolutely have to use the device files, then you could always change their permissions. Not that that's recommended, just saying.
regards, /W
2008/12/2 Wildemar Wildenburger wrote:
And if you absolutely have to use the device files, then you could always change their permissions. Not that that's recommended, just saying.
Changing permissions is not wise as it allows a user to bypass filesystem permissions.
A possibility is for the OP to read up on setuid and setgid; that offers the potential to restrict a user to what a program will allow rather than allowing unfettered access to a device (assuming no security holes in the application).
On Tue, Dec 02, 2008 at 01:53:56PM +0000, Paul Black wrote:
2008/12/2 Wildemar Wildenburger wrote:
And if you absolutely have to use the device files, then you could always change their permissions. Not that that's recommended, just saying.
Changing permissions is not wise as it allows a user to bypass filesystem permissions.
A possibility is for the OP to read up on setuid and setgid; that offers the potential to restrict a user to what a program will allow rather than allowing unfettered access to a device (assuming no security holes in the application).
I think most programmers tend to make it the user's prerogative to run the program using 'sudo' or 'su -c' to inherit the proper privileges. In other words, the permission error you're getting is something normal users should expect when they try to run against a device to which they don't have access. Elevating their privilege automatically inside a program is generally frowned upon.
hi...
check out how to handle/setup a superuser group (sudo) which allows a normal user to assume the role/privs of the root/superuser for a specifically defined task.
should handle your issue, if i understand what you're attempting. there should be examples on the 'net as well..
-----Original Message----- From: fedora-list-bounces@redhat.com [mailto:fedora-list-bounces@redhat.com]On Behalf Of wk Sent: Tuesday, December 02, 2008 1:21 AM To: fedora-list Subject: How can i call a function which is usually used by root?
I want write a c program.And a common user(not in root group) will run this program. In this program,I call fread(/dev/sdc...) and fwrite(/dev/sdc),but this call will return "permission no allow".If I use the root user,will be ok. How to change to the authority to root's?
I know the root's password.
--- On Tue, 12/2/08, bruce bedouglas@earthlink.net wrote:
From: bruce bedouglas@earthlink.net Subject: RE: How can i call a function which is usually used by root? To: "'Community assistance, encouragement, and advice for using Fedora.'" fedora-list@redhat.com Date: Tuesday, December 2, 2008, 4:04 PM hi...
check out how to handle/setup a superuser group (sudo) which allows a normal user to assume the role/privs of the root/superuser for a specifically defined task.
should handle your issue, if i understand what you're attempting. there should be examples on the 'net as well..
-----Original Message----- From: fedora-list-bounces@redhat.com [mailto:fedora-list-bounces@redhat.com]On Behalf Of wk Sent: Tuesday, December 02, 2008 1:21 AM To: fedora-list Subject: How can i call a function which is usually used by root?
I want write a c program.And a common user(not in root group) will run this program. In this program,I call fread(/dev/sdc...) and fwrite(/dev/sdc),but this call will return "permission no allow".If I use the root user,will be ok. How to change to the authority to root's?
I know the root's password.
-- fedora-list mailing list fedora-list@redhat.com To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
study the following... s bit is what you want:
consider the function passwd...allows the user to alter a file owned by root
How does one set the sticky bit and set UID bits with chmod?
octal digit> 1 2 3 4 octal value
4 set UID r r r
2 set GID w w w
1 sticky bit x x x
r read w write x execute s set UID or set GID t set sticky bit
chmod u+st filename chmod -R does down the tree