Publiccert
Publiccert

Reputation: 193

Authentication within python script

I'm writing a master-control script to control our infrastructure. Security is a major concern so I'd like to address two issues:

I want the user to be able to execute the application then be prompted to 'login' to the program using the root credentials on the system(Linux - Ubuntu). Failure to authenticate will trigger an email event and lock the program. Can I authenticate against /etc/passwd? And how can I lockout the application?

Second, how do I secure the application from modification? I may have to hard-code certain attributes into the application. What are the ideal permissions for a script to be executed but not edited?

Upvotes: 0

Views: 1615

Answers (1)

vz0
vz0

Reputation: 32933

While this is a non-trivial solution, the most secure way to do this is taking a client/server approach, making your master-control script a system service, only readable and runnable by root. You can fire up the service via init.d startup infrastructure.

When the service starts, you'd need to open a socket or RPC server to handle your control commands. On Python this can easily be done using Twisted.

To authenticate via /etc/passwd you can use the crypt and pwd Python modules.

Upvotes: 2

Related Questions