ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
HI,
I don't think that you can reboot the machine with out proper privileges. Do not use the system() call in your code. It will create serious security problems.
Originally posted by 64bitprocessor HI,
I don't think that you can reboot the machine with out proper privileges. Do not use the system() call in your code. It will create serious security problems.
why it will create serious security ? i don't undestand.
is there any posible to reboot without root acces ??
Linux is a multi user environment. This means it should allow multiple users to use a machine without the possibility of one user to affect other users. (unless badly configured of course). I assume you wouldn't want someone to reboot you machine while you are reading this. . So unless you have root access you can't reboot it.
If you do have root access and want to reboot it as a normal user (perhaps because you are the only user of the machine), you can configure it in someway but I'm sure it depends on the distribution. For my distribution it works ro run reboot, but I don't remember if it's a configuration that I have made, or it is the default.
Distribution: OpenSUSE 10.3 , 11.2 , Solaris 10, Ubuntu 9.10
Posts: 84
Rep:
When I restart programatically using an my GUI then it get started automatically next time when I start the pc . What to do with this ? I don't want my prog to start automatically next time .
Originally posted by •Vaan• actualy i want to make auto timer shutdown for linux, but i didn't have root acces. The target just local mechine.
is there any way to do it ?
HI all,
Create a C code with reboot(0x123456) to reboot the machine. Compile the program. Make the owner of the program as root and give suid permission to it. Now using this executable an ordinary user can reboot the machine.
Hi,
All the libraries are using the int reboot(int magic, int magic2, int flag, void *arg) system call for rebooting the system. See man 2 reboot for more details. This system call needs super user permission. Normally in Linux systems users are not allowed to reboot or turn off the systems because it is a multi-user system. So I don't think that there will be any other functions to reboot the machine with out privileged permission.
You can use the ordinary reboot(int) in Qt. There is no problem in that. But do not make large GUI programs SUID. It will create serious problems. SUID programs are so dangerous.
Last edited by 64bitprocessor; 07-04-2005 at 06:37 AM.
You can use ASM, C, C++ anything you want. But the user issuing the reboot command should be privileged. To understand the "serious problems” with system() call and SUID programs I have a sample code for you. Just try this.
main()
{
system("/bin/bash");
}
Compile this code as root. Change the permission of the executable to 711. Make the executable SUID and copy it to /bin.
Now login as an ordinary user and execute this program. You will get a shell with root's privilages!
Last edited by 64bitprocessor; 07-05-2005 at 12:18 AM.
thx, i have try it and it work so far in my mechine, because i did it by root acces.
but the problem if i haven't root acces to did it.
I haven't idea to reboot it with my less acces.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.