mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Move user logging and passing optional
Only pass the user in payload if it is not root and not the specified user from the configuration file. Those two users are implied to be the executor if there's no specific user. Log statements referencing the user have been wrapped in statements testing for the existence of the user key in the payload, otherwise log messages fall back to a non-user log message (it will continue to do this for root). This preserves backwards compatibility for masters that would never pass the user as well
This commit is contained in:
parent
6a80f56a77
commit
679a3843b1
@ -94,6 +94,11 @@ class LocalClient(object):
|
||||
for evar in env_vars:
|
||||
if evar in os.environ:
|
||||
return os.environ[evar]
|
||||
return None
|
||||
# If the running user is just the specified user in the
|
||||
# conf file, don't pass the user as it's implied.
|
||||
elif user == self.opts['user']:
|
||||
return None
|
||||
return user
|
||||
|
||||
def _check_glob_minions(self, expr):
|
||||
@ -454,31 +459,27 @@ class LocalClient(object):
|
||||
if not minions:
|
||||
return {'jid': '',
|
||||
'minions': minions}
|
||||
|
||||
# Generate the standard keyword args to feed to format_payload
|
||||
payload_kwargs = { 'cmd': 'publish',
|
||||
'tgt': tgt,
|
||||
'fun': fun,
|
||||
'arg': arg,
|
||||
'key': self.key,
|
||||
'tgt_type': expr_form,
|
||||
'ret': ret,
|
||||
'jid': jid }
|
||||
|
||||
# If we have a salt user, add it to the payload
|
||||
if self.salt_user:
|
||||
payload_kwargs['user'] = self.salt_user
|
||||
|
||||
# If we're a syndication master, pass the timeout
|
||||
if self.opts['order_masters']:
|
||||
package = salt.payload.format_payload(
|
||||
'clear',
|
||||
cmd='publish',
|
||||
tgt=tgt,
|
||||
fun=fun,
|
||||
arg=arg,
|
||||
key=self.key,
|
||||
tgt_type=expr_form,
|
||||
ret=ret,
|
||||
jid=jid,
|
||||
user=self.salt_user,
|
||||
to=timeout)
|
||||
else:
|
||||
package = salt.payload.format_payload(
|
||||
'clear',
|
||||
cmd='publish',
|
||||
tgt=tgt,
|
||||
fun=fun,
|
||||
arg=arg,
|
||||
key=self.key,
|
||||
tgt_type=expr_form,
|
||||
jid=jid,
|
||||
user=self.salt_user,
|
||||
ret=ret)
|
||||
payload_kwargs['to'] = timeout
|
||||
|
||||
package = salt.payload.format_payload( 'clear', **payload_kwargs)
|
||||
|
||||
# Prep zmq
|
||||
context = zmq.Context()
|
||||
socket = context.socket(zmq.REQ)
|
||||
|
@ -854,8 +854,12 @@ class ClearFuncs(object):
|
||||
if 'to' in clear_load:
|
||||
load['to'] = clear_load['to']
|
||||
|
||||
log.info(('User {0[user]} Published command {0[fun]} with jid'
|
||||
' {0[jid]}').format(clear_load))
|
||||
if 'user' in clear_load:
|
||||
log.info(('User {0[user]} Published command {0[fun]} with jid'
|
||||
' {0[jid]}').format(clear_load))
|
||||
else:
|
||||
log.info(('Published command {0[fun]} with jid'
|
||||
' {0[jid]}').format(clear_load))
|
||||
log.debug('Published command details {0}'.format(load))
|
||||
|
||||
payload['load'] = self.crypticle.dumps(load)
|
||||
|
@ -159,7 +159,12 @@ class Minion(object):
|
||||
# from returning a predictable exception
|
||||
#if data['fun'] not in self.functions:
|
||||
# return
|
||||
log.info('Executing command {0[fun]} with jid {0[jid]}'.format(data))
|
||||
if 'user' in data:
|
||||
log.info(('User {0[user]} Executing command {0[fun]} with jid '
|
||||
'{0[jid]}'.format(data)))
|
||||
else:
|
||||
log.info(('Executing command {0[fun]} with jid {0[jid]}'
|
||||
.format(data)))
|
||||
log.debug('Command details {0}'.format(data))
|
||||
self._handle_decoded_payload(data)
|
||||
|
||||
@ -472,9 +477,13 @@ class Syndic(salt.client.LocalClient, Minion):
|
||||
or 'to' not in data or 'arg' not in data:
|
||||
return
|
||||
data['to'] = int(data['to']) - 1
|
||||
log.debug(('Executing syndic command {0[fun]} with jid {0[jid]}'
|
||||
.format(data)))
|
||||
log.debug('Command details {0}'.format(data))
|
||||
if 'user' in data:
|
||||
log.debug(('User {0[user]} Executing syndic command {0[fun]} with '
|
||||
'jid {0[jid]}'.format(data)))
|
||||
else:
|
||||
log.debug(('Executing syndic command {0[fun]} with jid {0[jid]}'
|
||||
.format(data)))
|
||||
log.debug('Command details: {0}'.format(data))
|
||||
self._handle_decoded_payload(data)
|
||||
|
||||
def _handle_decoded_payload(self, data):
|
||||
|
Loading…
Reference in New Issue
Block a user