Re: [Spacewalk-devel] #!/usr/bin/env python to #!/usr/bin/python

2009-01-14 Thread Jan Pazdziora
On Wed, Jan 14, 2009 at 10:36:37AM +0100, Jan Pazdziora wrote:
 
 I propose to phase out
 
   #!/usr/bin/env python
 
 in favour of
 
   #!/usr/bin/python
 
 in our python scripts.
 
 Speak now or forever hold your peace.
 
 Note that we already use the second form 182 times in non-test
 scripts, while we use env 63 times.
 
 The current problem that I'm solving is that osa-dispatcher, when
 started via /usr/bin/env, will search directories for python, which
 generates SELinux AVC denials like
 
 type=AVC msg=audit(1231924839.798:5971): avc:  denied  { search } for  
 pid=15336 comm=python name=root dev=dm-0 ino=784129 
 scontext=root:system_r:osa_dispatcher_t:s0 
 tcontext=root:object_r:user_home_dir_t:s0 tclass=dir
 

Actually, this AVC denial is about different problem. So it was not
a good example.

But nevertheless: shouldn't we decide for env or direct path in the
shebang line and be consistent about it?

-- 
Jan Pazdziora
Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] #!/usr/bin/env python to #!/usr/bin/python

2009-01-14 Thread Pradeep Kilambi

Devan Goodwin wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wed, 14 Jan 2009 12:13:20 +0100
Jan Pazdziora jpazdzi...@redhat.com wrote:

  

On Wed, Jan 14, 2009 at 10:36:37AM +0100, Jan Pazdziora wrote:


I propose to phase out

#!/usr/bin/env python

in favour of

#!/usr/bin/python

in our python scripts.

Speak now or forever hold your peace.

Note that we already use the second form 182 times in non-test
scripts, while we use env 63 times.

The current problem that I'm solving is that osa-dispatcher, when
started via /usr/bin/env, will search directories for python, which
generates SELinux AVC denials like

type=AVC msg=audit(1231924839.798:5971): avc:  denied  { search }
for  pid=15336 comm=python name=root dev=dm-0 ino=784129
scontext=root:system_r:osa_dispatcher_t:s0
tcontext=root:object_r:user_home_dir_t:s0 tclass=dir

  

Actually, this AVC denial is about different problem. So it was not
a good example.

But nevertheless: shouldn't we decide for env or direct path in the
shebang line and be consistent about it?




+1. I'd go the other direction though and stick with /usr/bin/env
python, iirc that's considered best practice to accommodate people
with Python installed in a weird location or using multiple versions.

Devan
  


Agree with Devan on this. /usr/bin/env python is more  farsighted for 
users who have weird install locations. Else they i'll have to link 
/usr/bin/python each time they have new version. /usr/bin/env is more 
adaptable. I suggest changing the rest to this.


~ Prad

- -- 
Devan Goodwin dgood...@redhat.com

Software Engineer  Spacewalk / RHN
Satellite Halifax, Canada
650.567.9039x79267 Coming back to Java after a few months off is like
a slap in the face.
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAklt4UYACgkQAyHWaPV9my4/qACbBZ1YE/c9Vl0Xt4lxTR293Oth
cJgAnR3duyp7zEM02m64byk9vEfB6Uiq
=8N1T
-END PGP SIGNATURE-

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel
  


___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] #!/usr/bin/env python to #!/usr/bin/python

2009-01-14 Thread Jan Pazdziora
On Wed, Jan 14, 2009 at 08:57:38AM -0400, Devan Goodwin wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
  Actually, this AVC denial is about different problem. So it was not
  a good example.
  
  But nevertheless: shouldn't we decide for env or direct path in the
  shebang line and be consistent about it?
 
 +1. I'd go the other direction though and stick with /usr/bin/env
 python, iirc that's considered best practice to accommodate people
 with Python installed in a weird location or using multiple versions.

If you have Python in a weird location, you probably won't have
osa-dispatcher .py files installed in its PYTHONHOME, will you? So,
the first import which assumes that the python you run actually has
all the prerequisites installed, will fail. Alternatively, mixing
different pythons and libraries from different pythons might produce
weird results because symbols referenced in one library might not be
present in the library from that second python.

We actually have (non-public) bugzilla about this very problem. I'd
argue that we should stop pretending that /usr/bin/env python will
work in the general case, any just put /usr/bin/python there. If
someone needs to run it with different interpreter, they can always do

python /the/path/to/the/script

-- 
Jan Pazdziora
Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] #!/usr/bin/env python to #!/usr/bin/python

2009-01-14 Thread John Matthews

Devan Goodwin wrote:

On Wed, 14 Jan 2009 12:13:20 +0100
Jan Pazdziora jpazdzi...@redhat.com wrote:

  

On Wed, Jan 14, 2009 at 10:36:37AM +0100, Jan Pazdziora wrote:


I propose to phase out

#!/usr/bin/env python

in favour of

#!/usr/bin/python

in our python scripts.

Speak now or forever hold your peace.

Note that we already use the second form 182 times in non-test
scripts, while we use env 63 times.

The current problem that I'm solving is that osa-dispatcher, when
started via /usr/bin/env, will search directories for python, which
generates SELinux AVC denials like

type=AVC msg=audit(1231924839.798:5971): avc:  denied  { search }
for  pid=15336 comm=python name=root dev=dm-0 ino=784129
scontext=root:system_r:osa_dispatcher_t:s0
tcontext=root:object_r:user_home_dir_t:s0 tclass=dir

  

Actually, this AVC denial is about different problem. So it was not
a good example.

But nevertheless: shouldn't we decide for env or direct path in the
shebang line and be consistent about it?




+1. I'd go the other direction though and stick with /usr/bin/env
python, iirc that's considered best practice to accommodate people
with Python installed in a weird location or using multiple versions.

Devan
  

I agree with Devan, and prefer the env usage.



___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] #!/usr/bin/env python to #!/usr/bin/python

2009-01-14 Thread Clifford Perry

Jan Pazdziora wrote:

On Wed, Jan 14, 2009 at 08:57:38AM -0400, Devan Goodwin wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


Actually, this AVC denial is about different problem. So it was not
a good example.

But nevertheless: shouldn't we decide for env or direct path in the
shebang line and be consistent about it?

+1. I'd go the other direction though and stick with /usr/bin/env
python, iirc that's considered best practice to accommodate people
with Python installed in a weird location or using multiple versions.


If you have Python in a weird location, you probably won't have
osa-dispatcher .py files installed in its PYTHONHOME, will you? So,
the first import which assumes that the python you run actually has
all the prerequisites installed, will fail. Alternatively, mixing
different pythons and libraries from different pythons might produce
weird results because symbols referenced in one library might not be
present in the library from that second python.

We actually have (non-public) bugzilla about this very problem. I'd
argue that we should stop pretending that /usr/bin/env python will
work in the general case, any just put /usr/bin/python there. If
someone needs to run it with different interpreter, they can always do

python /the/path/to/the/script



I would prefer the hard code path to the python binary for reasons 
stated by Jan above.


Folks - other than preference normally - please give feedback based on 
this above information.


Cliff


--
Clifford Perry
Manager, Satellite Engineering
Red Hat, Inc.
http://www.redhat.com/
+1 919 754 4403
RHCA / RHCE# 805007680128201

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] #!/usr/bin/env python to #!/usr/bin/python

2009-01-14 Thread Michael DeHaan

Clifford Perry wrote:

Jan Pazdziora wrote:

On Wed, Jan 14, 2009 at 08:57:38AM -0400, Devan Goodwin wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


Actually, this AVC denial is about different problem. So it was not
a good example.

But nevertheless: shouldn't we decide for env or direct path in the
shebang line and be consistent about it?

+1. I'd go the other direction though and stick with /usr/bin/env
python, iirc that's considered best practice to accommodate people
with Python installed in a weird location or using multiple versions.


If you have Python in a weird location, you probably won't have
osa-dispatcher .py files installed in its PYTHONHOME, will you? So,
the first import which assumes that the python you run actually has
all the prerequisites installed, will fail. Alternatively, mixing
different pythons and libraries from different pythons might produce
weird results because symbols referenced in one library might not be
present in the library from that second python.

We actually have (non-public) bugzilla about this very problem. I'd
argue that we should stop pretending that /usr/bin/env python will
work in the general case, any just put /usr/bin/python there. If
someone needs to run it with different interpreter, they can always do

python /the/path/to/the/script



I would prefer the hard code path to the python binary for reasons 
stated by Jan above.


Folks - other than preference normally - please give feedback based on 
this above information.


Cliff



I'd suggest /usr/bin/python without the env.

If the RPM doesn't work with the distribution-specific Python, things 
are quite busted, and folks shouldn't expect them to work.


We do not package two python versions, and the modules won't be properly 
installed as required by the RPM.


--Michael


___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel