LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Operation not permitted (https://www.linuxquestions.org/questions/linux-general-1/operation-not-permitted-366957/)

jakkals 09-25-2005 03:11 PM

Operation not permitted
 
I get the following when running a program as a normal user (not root):
wwwrun@fsx01:~> /usr/local/bin/k74 1 set
/dev/port: Operation not permitted


Here is the code that sets the bit on 0x378 (parport 0) - c code:
void out_byte(int port, unsigned char byte)
{
off_t s;
int r;

s = lseek(dev_port_fd, port, 0);
if (s < 0) perror("lseek");
else if (s != port)
fprintf(stderr, "hmmm: seeking to %d, went to %ld.\n", port, (long)s);

r = write(dev_port_fd, &byte, 1);
if (r != 1)
{
fprintf(stderr, "hmmm: write returned %d\n", r);
if (r < 0) perror("write");
}
}

I have tried numerous options such as setting read-write on the devices and /dev/port and the app (k74) etc, nothing works.

I want to do this because I want php to execute the command (remote control garden system via wap). At this stage I have added apache to the sudoers list and it works. When running the command as apache in CONSOLE, it works fine, but as soon as I run it using php (web): shell_exec,exec,passthru, nothing happen :(

Any ideas anyone?

geeman2.0 09-26-2005 09:41 AM

Sorry, I'm not sure I quite understand your question.
Are you saying that the program runs as a priveleged (root) user but not as a normal user?

Note that the lower ports are reserved for root usage only and only the higher ports are accessible as a regular user. (Thus why apache must be started with root priveleges)

jakkals 09-26-2005 03:11 PM

the program can only run as a root user due to its nature. apache does not run as this user (should not anyways). How can I execute this program using php in apache?

tkedwards 09-26-2005 07:30 PM

Quote:

apache does not run as this user (should not anyways)
Apache does actually start as root always. On a properly configured systems it will then fork off one or more child processes running as a non-priveleged user to handle requests. However the initial stub process still has to run in order to stay bound to the port. Do a ps -ef on your apache system and you should see an apache process started as root.


All times are GMT -5. The time now is 11:35 AM.