Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm doing development with PyCharm, doing development on a script that uses the scapy module for Python to do port scans, sniff traffic, and build raw packets. This, of course, requires root permissions, and so I run PyCharm as root (Yes, I'm aware of the security issues this presents).

The problem is, when PyCharm contacts the company license server, it submits the current username, which of course, ends up being "root", and the license server rejects my request. If I don't launch PyCharm as root, then it submits my actual username and successfully gets a license, but then I can't run my script because it needs root permissions to do the things it does.

Is there a way to make PyCharm run and submit my actual username to the license server, but then have root privileges, without just editing my account to give myself root permissions?

share|improve this question

1 Answer 1

I imagine sudo would be perfect for this. As a quick test:

$ echo $USER
halosghost
$ sudo echo $USER
[sudo] password for halosghost:
halosghost

That is, I have hightened permissions, but maintain my user's identity. The -E flag may also be particularly useful. It makes sure the environment variables are preserved during execution.

share|improve this answer
    
I was using sudo before and it wasn't working. PyCharm started, but couldn't get a license from the server. I did it now and it worked. It might be worth mentioning that while doing "sudo echo $USER" does show my username and not root, "sudo whoami" tells me I'm root. EDIT: I'm wondering if there's someone else in the company also using PyCharm as root, and my license request was failing because someone else was already holding the license using "root" as the username. I'm not sure exactly how PyCharm's floating licenses work. –  Sohcahtoa82 Jun 6 at 20:35
    
It would be helpful to know how PyCharm detects your username. –  HalosGhost Jun 6 at 20:40
    
Indeed it would. From within PyCharm, I opened a Python console and used it to check environment variables, and LOGNAME, USERNAME, and USER are all "root". SUDO_USER is of course my actual username. If I run os.system('echo $USER') from that prompt, it tells me I'm root. So it looks like it is probably still telling the license server that I'm root, the server has just decided to give me a license this time, for some reason. –  Sohcahtoa82 Jun 6 at 20:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.