: : : I am writing a program that uses a library that needs root access in
: : : linux and administator rights in Windows. How do I gain access in
: : : code?
: : : Just my 2 bits
: : under linux you can write a shell script that starts your java
: : program as root (have a look at suid root). maybe you should try to
: : get around this. and what are you doing so that you need admin right
: : under windows? This sounds a little strange to me...
:
: I am capturing packets using the Jpcap library(not jpcap) and it
: requires root access in *nix and admin in Windows. The program I am
: writing does not always use this library so doesn't need root. I was
: just hoping I could drop root privileges when it is not needed.
:
:
: Just my 2 bits
From a security standpoint it should be impossible for a program to arbitrarily turn root access on or off. Image visiting a website, which installs an activeX control/applet on your computer, then turns on root access for itself and implant a backdoor, virus, or other malware.
A workaround for your program would be to inform the user that capturing packets is not possible, when he has less than root access. You could also disable the controls, which activate the capturing when you don't have root access.