java - Restart jar with root privileges on most (if not all) Linux distributions -


i developing java application requires root/administrator privileges function properly. if user not start application such privileges, notify user , restart program these privileges. have figured out how on windows , os x cannot find way on linux systems. on windows, found program elevates command pass it, on os x possible through running simple applescript on linux, there no portable way it.

my plan use gksu discovered not installed default on linux systems , neither debian cannot install either. there portable way restart application root privileges on most, if not all, linux distros , flavours in java?

edit: able check if program running administrator on platforms.

you're not going able cleanly on linux** because idea of escalating privileges doesn't exist in linux. sudo de facto answer privileged execution, that's doing running single command root, conceptually distinct running command same user escalated privileges.

consider fact baseline sudo (not considering gksudo or like) userspace application , not core component of linux. on arch, example, might have not ever installed if prefer things su.

this philosophy contrasts sharply os x , windows, desktop-focused , find convenient blur line between administration , regular usage. because linux uses same kernel both desktop , server distributions, heightened security requirements of server environment tend dominate policies around these kinds of things @ kernel level , you're not going solution isn't specific class of desktop-oriented distributions.

there's cultural difference; linux users tend kind of people want fine grained control on how run things , view restarts root privileges form of virus :p

easy answer: throw out error message saying application needs root privileges, exit non-zero error code, call day. that's more or less "expected" behavior in linux-land.

hack-y answer: if you're going running in graphical environment link gksudo dependency along gtk (or kdesudo if you're using qt or something, etc etc) , use prompt escalation. if it's not installed default, you'll leverage linux distros' fancy package management installed without effort on part of user's. in non-graphical environment you're out of luck.

** @ least, not enough worth 1 application, considering application can become attack vector trying write new rootkit.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -