Re: python34 and selinux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2016-04-18 at 14:38 +1000, William wrote:
> > 
> > For the general info you can use help():
> > 
> > # python3
> > > 
> > > 
> > > > 
> > > > 
> > > > > 
> > > > > 
> > > > > import selinux
> > > > > help(selinux)
> > > > > import semanage
> > > > > help(semanage)
> > e.g.
> > > 
> > > 
> > > > 
> > > > 
> > > > > 
> > > > > 
> > > > > selinux.is_selinux_enabled()
> > 1
> > > 
> > > 
> > > > 
> > > > 
> > > > > 
> > > > > 
> > > > > selinux.selinux_getpolicytype()
> > [0, 'targeted']
> > 
> Perfect! This is exactly what I needed. Thanks for your advice,
> 
> 

I keep getting errors trying to use this. And all the help pages have
documentation like:

    semanage_port_exists(...)

Which is not very helpful.

So from reading /usr/lib64/python3.4/site-packages/semanage.py I am at:


>>> import semanage
>>> import selinux
>>> h = semanage.semanage_handle_create()
>>> semanage.semanage_connect(h)
>>> (r, k) = semanage.semanage_port_key_create(h, 389, 389,
semanage.SEMANAGE_PROTO_TCP)

>>> semanage.semanage_port_exists_local(h, k)
[4, 0]
>>> semanage.semanage_port_query(h, k)
[4, <Swig Object of type 'struct semanage_port *' at 0x7f1b04ce3b10>]

>>> (r, k) = semanage.semanage_port_key_create(h, 38579, 38579,
semanage.SEMANAGE_PROTO_TCP)
>>> semanage.semanage_port_query(h, k)
[4, None]

What do these results even mean ....? I guess in the first, 0, means it does
exist, where as the later port_query, None means it doesn't? The second is giving
me the struct of type that owns the port? 

Any help on these return values would be great.

-- 
William <william@xxxxxxxxxxxxxxxx>
--
selinux mailing list
selinux@xxxxxxxxxxxxxxxxxxxxxxx
http://lists.fedoraproject.org/admin/lists/selinux@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux