Re: [PATCH] SysctlModule

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

 



Luke Macken wrote:
On Wed, Jan 23, 2008 at 10:55:05AM +0100, Jan Pazdziora wrote:
On Mon, Jan 21, 2008 at 09:55:40PM -0500, Luke Macken wrote:
Does anyone have any interest in a sysctl module ?

This allows you to weak your minion's kernel parameters at runtime, ie:

    # func "*" call sysctl get net.ipv4.icmp_echo_ignore_broadcasts
    ['1']
    # func "*" call sysctl set net.ipv4.tcp_syncookies 1
    ['net.ipv4.tcp_syncookies = 1']
[...]

+    def __run(self, cmd):
+        cmd = sub_process.Popen(cmd.split(), stdout=sub_process.PIPE,
+                                stderr=sub_process.PIPE, shell=False)
+        return [line for line in cmd.communicate()[0].strip().split('\n')]
+
+    def list(self):
+        return self.__run("/sbin/sysctl -a")
+
+    def get(self, name):
+        return self.__run("/sbin/sysctl -n %s" % name)
+
+    def set(self, name, value):
+        return self.__run("/sbin/sysctl -w %s=%s" % (name, value))
Could we avoid joining data in order to split them later? I recently
went through a rather painful process of cleaning the
space/escape/shell metacharacter issues in one project, so my gut
feeling is it will bite us one day ...

I'm not quite sure I fully understand what you are trying to get
at.  Care to elaborate on whatever questionable aspects of this module
you think will "bite us" someday ?


luke

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

Ideally any module that is doing really important stuff should probably be returning formatted data rather than just an array of lines from stdin/stdout.
Parsing is fragile in the long run.

However in this case, it's clearly a low level sort of thing, so I am not sure how important the return values actually are.

--Michael


_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux