Skip to content

Commit 3eb7d17

Browse files
committed
Finished up documentation, fix #24
1 parent 2ece10c commit 3eb7d17

File tree

20 files changed

+433
-50
lines changed

20 files changed

+433
-50
lines changed

docs/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ Particularly, some `appliances (Proxmox, XCP-ng and KVM) are prepared <https://d
3131
:hidden:
3232

3333
python/shares.rst
34+
python/ldapHelper.rst
35+
python/realm.rst
36+
python/printers.rst
3437
python/computer.rst
38+
python/user.rst
3539
python/config.rst
36-
python/environment.rst
37-
python/fileHelper.rst
38-
python/gpo.rst
39-
python/hooks.rst
40-
python/imageHelper.rst
40+
python/otherHelpers.rst

docs/python/environment.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/python/fileHelper.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/python/gpo.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/python/hooks.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/python/imageHelper.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/python/ldapHelper.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Module: ldapHelper
2+
******************
3+
4+
This module is used to deal with all LDAP tasks, like performing searches and checking group memberships.
5+
6+
Members
7+
=======
8+
.. automodule:: linuxmusterLinuxclient7.ldapHelper
9+
:members:

docs/python/otherHelpers.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Other helper modules
2+
********************
3+
4+
Module: logging
5+
===============
6+
7+
This module is used to deal with all logs. It not only prints them but also writes them to `/var/log/syslog`
8+
9+
Members
10+
-------
11+
.. automodule:: linuxmusterLinuxclient7.logging
12+
:members:
13+
14+
Module: localUserHelper
15+
=======================
16+
17+
This module is used to deal with local users.
18+
19+
Members
20+
-------
21+
.. automodule:: linuxmusterLinuxclient7.localUserHelper
22+
:members:
23+
24+
Module: setup
25+
=================
26+
27+
This module is used to setup, clean and upgrade the client.
28+
29+
Members
30+
-------
31+
.. automodule:: linuxmusterLinuxclient7.seup
32+
:members:
33+
34+
Module: imageHelper
35+
===================
36+
37+
This module is used to prepare a client for imaging.
38+
39+
Members
40+
-------
41+
.. automodule:: linuxmusterLinuxclient7.imageHelper
42+
:members:
43+
44+
Module: hooks
45+
=============
46+
47+
This module is used to deal with local hookdirs in `/etc/linuxmuster-linuxclient7` and the sysvol.
48+
49+
Members
50+
-------
51+
.. automodule:: linuxmusterLinuxclient7.hooks
52+
:members:
53+
54+
Module: gpo
55+
===========
56+
57+
This module is used to deal with Microsoft GPOs.
58+
59+
Members
60+
-------
61+
.. automodule:: linuxmusterLinuxclient7.gpo
62+
:members:
63+
64+
Module: fileHelper
65+
==================
66+
67+
This module is used to deal files.
68+
69+
Members
70+
-------
71+
.. automodule:: linuxmusterLinuxclient7.fileHelper
72+
:members:
73+
74+
Module: environment
75+
===================
76+
77+
This module is used to export and unset environment variables during the onLogin/logon hook.
78+
79+
Members
80+
-------
81+
.. automodule:: linuxmusterLinuxclient7.environment
82+
:members:
83+
84+
Module: keytab
85+
==============
86+
87+
This module is used to manage the keytab (`/etc/krb5.keytab`) file.
88+
89+
Members
90+
-------
91+
.. automodule:: linuxmusterLinuxclient7.keytab
92+
:members:
93+
94+
Module: templates
95+
=================
96+
97+
This module is used to manage templates for config files.
98+
99+
Members
100+
-------
101+
.. automodule:: linuxmusterLinuxclient7.templates
102+
:members:

docs/python/printers.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Module: printers
2+
****************
3+
4+
This module is used to deal with networked printers
5+
6+
Members
7+
=======
8+
.. automodule:: linuxmusterLinuxclient7.printers
9+
:members:

docs/python/realm.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Module: realm
2+
*************
3+
4+
This module is used to deal with all AD related things:
5+
6+
* Discovering domains
7+
* Joining domains
8+
* Leaving domains
9+
* Clearing the local user cache
10+
* Pulling kerberos tickets using the computer account
11+
12+
Members
13+
=======
14+
.. automodule:: linuxmusterLinuxclient7.realm
15+
:members:

docs/python/user.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Module: user
2+
************
3+
4+
This module is used to deal with users and their properties, like username and groups.
5+
6+
Members
7+
=======
8+
.. automodule:: linuxmusterLinuxclient7.user
9+
:members:

usr/lib/python3/dist-packages/linuxmusterLinuxclient7/keytab.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
from linuxmusterLinuxclient7 import computer, config, logging
33

44
def patchKeytab():
5+
"""
6+
Patches the `/etc/krb5.keytab` file. It inserts the correct hostname of the current computer.
7+
8+
:return: True on success, False otherwise
9+
:rtype: bool
10+
"""
511
krb5KeytabFilePath = "/etc/krb5.keytab"
612
logging.info("Patching {}".format(krb5KeytabFilePath))
713
krb5KeytabUtil = Krb5KeytabUtil(krb5KeytabFilePath)

usr/lib/python3/dist-packages/linuxmusterLinuxclient7/ldapHelper.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
_currentLdapConnection = None
55

66
def serverUrl():
7+
"""
8+
Returns the server URL
9+
10+
:return: The server URL
11+
:rtype: str
12+
"""
713
rc, networkConfig = config.network()
814

915
if not rc:
@@ -13,6 +19,12 @@ def serverUrl():
1319
return 'ldap://{0}'.format(serverHostname)
1420

1521
def baseDn():
22+
"""
23+
Returns the base DN
24+
25+
:return: The baseDN
26+
:rtype: str
27+
"""
1628
rc, networkConfig = config.network()
1729

1830
if not rc:
@@ -22,6 +34,12 @@ def baseDn():
2234
return "dc=" + domain.replace(".", ",dc=")
2335

2436
def conn():
37+
"""
38+
Returns the ldap connection object
39+
40+
:return: The ldap connection object
41+
:rtype: ldap.ldapobject.LDAPObject
42+
"""
2543
global _currentLdapConnection
2644

2745
if _connect():
@@ -30,6 +48,13 @@ def conn():
3048
return None
3149

3250
def searchOne(filter):
51+
"""Searches the LDAP with a filter and returns the first found object
52+
53+
:param filter: A valid ldap filter
54+
:type filter: str
55+
:return: Tuple (success, ldap object as dict)
56+
:rtype: tuple
57+
"""
3358
if conn() == None:
3459
logging.error("Cannot talk to LDAP")
3560
return False, None
@@ -72,6 +97,16 @@ def searchOne(filter):
7297
return False, None
7398

7499
def isObjectInGroup(objectDn, groupName):
100+
"""
101+
Check if a given object is in a given group
102+
103+
:param objectDn: The DN of the object
104+
:type objectDn: str
105+
:param groupName: The name of the group
106+
:type groupName: str
107+
:return: True if it is a member, False otherwise
108+
:rtype: bool
109+
"""
75110
logging.debug("= Testing if object {0} is a member of group {1} =".format(objectDn, groupName))
76111
rc, groupAdObject = searchOne("(&(member:1.2.840.113556.1.4.1941:={0})(sAMAccountName={1}))".format(objectDn, groupName))
77112
logging.debug("=> Result: {} =".format(rc))

usr/lib/python3/dist-packages/linuxmusterLinuxclient7/localUserHelper.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
from linuxmusterLinuxclient7 import logging
33

44
def getGroupsOfLocalUser(username):
5+
"""
6+
Get all groups of a local user
7+
8+
:param username: The username of the user
9+
:type username: str
10+
:return: Tuple (success, list of groups)
11+
:rtype: tuple
12+
"""
513
try:
614
groups = subprocess.check_output(["id", "-Gnz", username])
715
stringList=[x.decode('utf-8') for x in groups.split(b"\x00")]

usr/lib/python3/dist-packages/linuxmusterLinuxclient7/logging.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,70 @@ class Level(Enum):
1010
FATAL = 4
1111

1212
def debug(message):
13+
"""
14+
Do a debug log.
15+
16+
:param message: The message to log
17+
:type message: str
18+
"""
1319
_log(Level.DEBUG, message)
1420

1521
def info(message):
22+
"""
23+
Do an info log.
24+
25+
:param message: The message to log
26+
:type message: str
27+
"""
1628
_log(Level.INFO, message)
1729

1830
def warning(message):
31+
"""
32+
Do a warning log.
33+
34+
:param message: The message to log
35+
:type message: str
36+
"""
1937
_log(Level.WARNING, message)
2038

2139
def error(message):
40+
"""
41+
Do an error log.
42+
43+
:param message: The message to log
44+
:type message: str
45+
"""
2246
_log(Level.ERROR, message)
2347

2448
def fatal(message):
49+
"""
50+
Do a fatal log. If used in onLogin hook, this will create a dialog containing the message.
51+
52+
:param message: The message to log
53+
:type message: str
54+
"""
2555
_log(Level.FATAL, message)
2656

2757
def exception(exception):
58+
"""
59+
Log an exception
60+
61+
:param exception: The exception to log
62+
:type exception: Exception
63+
"""
2864
error("=== An exception occurred ===")
2965
error(str(exception))
3066
# Only use for debugging! This will cause ugly error dialogs in X11
3167
#traceback.print_tb(exception.__traceback__)
3268
error("=== end exception ===")
3369

3470
def printLogs(compact=False):
71+
"""
72+
Print logs of linuxmuster-linuxclient7 from `/var/log/syslog`.
73+
74+
:param compact: If set to True, some stuff like time and date will be removed. Defaults to False
75+
:type compact: bool, optional
76+
"""
3577
print("===========================================")
3678
print("=== Linuxmuster-linuxclient7 logs begin ===")
3779

0 commit comments

Comments
 (0)