Jonathan Hurley created AMBARI-18824:
----------------------------------------

             Summary: MOTD Can Prevent WebHCat From Shutting Down
                 Key: AMBARI-18824
                 URL: https://issues.apache.org/jira/browse/AMBARI-18824
             Project: Ambari
          Issue Type: Bug
          Components: ambari-server
    Affects Versions: 2.4.0
            Reporter: Jonathan Hurley
            Assignee: Jonathan Hurley
            Priority: Blocker
             Fix For: 2.4.2


There was code added in AMBARI-12695 (later corrected by AMBARI-18684) which 
tries to kill WebHCat if it doesn't stop with its own stop command.

Both patches use the {{as_user}} function to wrap the call in a bash login:
{code}
ps -p `su hcat -l -s /bin/bash -c 'cat /var/run/webhcat/webhcat.pid'` 
>/dev/null 2>&1
{code}

This, however, causes problems where there is a MOTD:
{code}
ERROR: Process ID list syntax error.
********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real group ID (supports names)
-a all w/ tty except session leaders  -U by real user ID (supports names)
-d all except session leaders         -g by session OR by effective group name
-e all processes                      -p by process ID
                                      -q by process ID (unsorted & quick)
T  all processes on this terminal     -s processes in the sessions given
a  all w/ tty, including other users  -t by tty
g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
r  only running processes             U  processes for specified users
x  processes w/o controlling ttys     t  by tty
*********** output format **********  *********** long options ***********
-o,o user-defined  -f full            --Group --User --pid --cols --ppid
-j,j job control   s  signal          --group --user --sid --rows --info
-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
-l,l long          u  user-oriented   --sort --tty --forest --version
-F   extra full    X  registers       --heading --no-heading --context
                                      --quick-pid
                    ********* misc options *********
-V,V  show version      L  list format codes  f  ASCII art forest
-m,m,-L,-T,H  threads   S  children in sum    -y change -l format
-M,Z  security data     c  true command name  -c scheduling class
-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy
{code}

That's not good - why is it giving us back a bad command syntax? Here's the 
reason:
{code}
[root@ijzs-c229todgsecha-r6-re1-3 ~]# su hcat -l -s /bin/bash -c 'cat 
/var/run/webhcat/webhcat.pid'
This is MOTD message :)
25672
{code}

*The MOTD is messing up the output from commands for the {{hcat}} user. Because 
we rely on the error code of {{ps}}, the same non-zero code is used for a bad 
command and a missing process ID*.

Since the PID is world-readable, we don't need to run the {{only_if}} checks as 
a separate user.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to