|
|
|
@ -1,3 +1,57 @@
|
|
|
|
|
diff -ur a/salt/grains/core.py b/salt/grains/core.py
|
|
|
|
|
--- a/salt/grains/core.py 2015-07-07 15:42:37.000000000 -0500
|
|
|
|
|
+++ b/salt/grains/core.py 2015-07-10 16:24:29.097483841 -0500
|
|
|
|
|
@@ -1042,28 +1042,29 @@
|
|
|
|
|
with salt.utils.fopen('/proc/1/cmdline') as fhr:
|
|
|
|
|
init_cmdline = fhr.read().replace('\x00', ' ').split()
|
|
|
|
|
init_bin = salt.utils.which(init_cmdline[0])
|
|
|
|
|
- supported_inits = ('upstart', 'sysvinit', 'systemd')
|
|
|
|
|
- edge_len = max(len(x) for x in supported_inits) - 1
|
|
|
|
|
- buf_size = __opts__['file_buffer_size']
|
|
|
|
|
- try:
|
|
|
|
|
- with open(init_bin, 'rb') as fp_:
|
|
|
|
|
- buf = True
|
|
|
|
|
- edge = ''
|
|
|
|
|
- buf = fp_.read(buf_size).lower()
|
|
|
|
|
- while buf:
|
|
|
|
|
- buf = edge + buf
|
|
|
|
|
- for item in supported_inits:
|
|
|
|
|
- if item in buf:
|
|
|
|
|
- grains['init'] = item
|
|
|
|
|
- buf = ''
|
|
|
|
|
- break
|
|
|
|
|
- edge = buf[-edge_len:]
|
|
|
|
|
+ if init_bin:
|
|
|
|
|
+ supported_inits = ('upstart', 'sysvinit', 'systemd')
|
|
|
|
|
+ edge_len = max(len(x) for x in supported_inits) - 1
|
|
|
|
|
+ buf_size = __opts__['file_buffer_size']
|
|
|
|
|
+ try:
|
|
|
|
|
+ with open(init_bin, 'rb') as fp_:
|
|
|
|
|
+ buf = True
|
|
|
|
|
+ edge = ''
|
|
|
|
|
buf = fp_.read(buf_size).lower()
|
|
|
|
|
- except (IOError, OSError) as exc:
|
|
|
|
|
- log.error(
|
|
|
|
|
- 'Unable to read from init_bin ({0}): {1}'
|
|
|
|
|
- .format(init_bin, exc)
|
|
|
|
|
- )
|
|
|
|
|
+ while buf:
|
|
|
|
|
+ buf = edge + buf
|
|
|
|
|
+ for item in supported_inits:
|
|
|
|
|
+ if item in buf:
|
|
|
|
|
+ grains['init'] = item
|
|
|
|
|
+ buf = ''
|
|
|
|
|
+ break
|
|
|
|
|
+ edge = buf[-edge_len:]
|
|
|
|
|
+ buf = fp_.read(buf_size).lower()
|
|
|
|
|
+ except (IOError, OSError) as exc:
|
|
|
|
|
+ log.error(
|
|
|
|
|
+ 'Unable to read from init_bin ({0}): {1}'
|
|
|
|
|
+ .format(init_bin, exc)
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
# Add lsb grains on any distro with lsb-release
|
|
|
|
|
try:
|
|
|
|
|
diff -ur a/tests/unit/modules/artifactory_test.py b/tests/unit/modules/artifactory_test.py
|
|
|
|
|
--- a/tests/unit/modules/artifactory_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
|
|
|
+++ b/tests/unit/modules/artifactory_test.py 2015-07-10 12:11:33.942671443 -0500
|
|
|
|
|