473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Let users execute but not view

Hi!
I have a python script which should be executed my normal users but they
should not be able to view the sourcecode. Setting permissions to x only
does not help, the python interpreter can not read the file.
How can I do that?
Thanks,
Florian
Jul 18 '05 #1
5 1230
Florian Lindner wrote:
Hi!
I have a python script which should be executed my normal users but they
should not be able to view the sourcecode. Setting permissions to x only
does not help, the python interpreter can not read the file.
How can I do that?
Thanks,
Florian


I believe that the common thing to do is to remove the .py file but
leave the compiled .pyc file, which is rather more difficult to
reverse-engineer. Not impossible of course.

However, I'm only a newbe and others may know a better way.

Steve
Jul 18 '05 #2
Florian Lindner wrote:
Hi!
I have a python script which should be executed my normal users
but they should not be able to view the sourcecode. Setting
permissions to x only does not help, the python interpreter can
not read the file. How can I do that?


Compile it to a .pyc file and give that to your users instead of
the .py file. You can use py_compile or compileall in the Python
standard libraries for this.

Note, however, that this does not protect you from the really
inquisitive or from malicious users and so on. They could use
dis, for example, from the Python standard library to learn about
your code.

Dave

--
http://www.rexx.com/~dkuhlman
dk******@rexx.com
Jul 18 '05 #3
Florian Lindner fed this fish to the penguins on Sunday 04 January 2004
11:06 am:


Hi!
I have a python script which should be executed my normal users but
they should not be able to view the sourcecode. Setting permissions to
x only does not help, the python interpreter can not read the file.
How can I do that?
Create .pyc (or .pyo) files for all the modules, remove the sources,
and use a very short .py file that just imports the main program and
runs its entry point...

Tedious, but it does add a layer of hassle to anyone trying to get
into it.

No perfect, as there are ways to "decompile" the .pyc files and get
the gist of what is being performed.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Bestiaria Home Page: http://www.beastie.dm.net/ <
Home Page: http://www.dm.net/~wulfraed/ <


Jul 18 '05 #4
"Florian Lindner" <Fl*************@xgm.de> wrote in message
news:bt*************@news.t-online.com...
Hi!
I have a python script which should be executed my normal users but they
should not be able to view the sourcecode. Setting permissions to x only
does not help, the python interpreter can not read the file.
How can I do that?
Thanks,
Florian


You've already got the standard answers, hopefully that will do
what you need to do.

The other way is to dig into the import mechanics, paying
particular attention to how it unfreezes frozen modules,
and then arrange to decrypt your encrypted pre-compiled
modules when they have to be imported.

That's a *lot* of hassle, and I don't know of anyone
who's actually done it. Whether the work is worth
the benefit is, of course, your decision.

John Roth
Jul 18 '05 #5
Hi Florian,

Check this link from Python's programming FAQ to create compiled
code from .py files:

http://www.python.org/doc/faq/progra...ate-a-pyc-file

The "dis" module can be used to disassemble and examine this byte
code. But
creating a .pyc file should suffice your requirements.

-Raghav.

Florian Lindner <Fl*************@xgm.de> wrote in message news:<bt*************@news.t-online.com>...
Hi!
I have a python script which should be executed my normal users but they
should not be able to view the sourcecode. Setting permissions to x only
does not help, the python interpreter can not read the file.
How can I do that?
Thanks,
Florian

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Geomancer | last post by:
Check-out this story on DBAZine: http://www.dbazine.com/burleson14.shtml I have end-users just like these. The illustration are hilarous!
3
by: Peter Sands | last post by:
Hi, Some of my users would like to use the 'list applications' command to view processes being run. But I do not want them to belong to the SYSMAINT group or any other system group(...
4
by: deko | last post by:
Is there any way to let users compose and run SQL from the Access interface? If I create a new query from the Database Window, select Design View and then View >> SQL View, I get a window from...
2
by: PB | last post by:
I need to enable users to download data in either an Excel file or an Access database (MDB file). The data they need exists in a SQL Server database: the XLS or MDB file does not actually exist...
1
by: Sam | last post by:
Hi, I have created a web service and I'm using google map API. If I write a particular URL like this:...
6
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am thinking about doing this since I got several cases that some of our internal users open more than one browser at the same time from our server. When one of the transactions was not...
4
by: gmazza | last post by:
Hi there, I am trying to insert 4 fields into a table grabbing the 4 fields from a form, here is my code: Private Sub LastPaymentAmount_AfterUpdate() Dim CurrentProject As DAO.Database Set...
1
parajaganesh
by: parajaganesh | last post by:
I am using Windows ClearCase Explorer. I do some scripting process to create a new view in ClearCase. But it cannot be displayed in the current screen. We need to press Alt + F5 after running my...
7
by: Gary | last post by:
Hello guys! Bear with me, I am a newbie. She is the Data Warehouse manager. She has about 50 users to use the Oracle database from M$ Access via ODBC connection. All those users have only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.