From b97ff49fc2babcf5d0739b38f59399d9dcc60d97 Mon Sep 17 00:00:00 2001 From: Aron Parsons Date: Fri, 29 Mar 2019 14:07:35 -0400 Subject: [PATCH] exit non-zero when user does not exist $ ./su-exec realuser id; echo $? uid=12345(realuser) ... 0 $ ./su-exec fakeuser id; echo $? user fakeuser does not exist 1 fixes https://github.com/ncopa/su-exec/issues/6 --- su-exec | Bin 0 -> 16808 bytes su-exec.c | 8 +++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 su-exec diff --git a/su-exec b/su-exec new file mode 100755 index 0000000000000000000000000000000000000000..424abc22f0c6017661a14c1e51e68d7dd19fa921 GIT binary patch literal 16808 zcmeHOdvIJ=c|Uj8THUqm)yi^g$%c3daUv76l3zk`60)+r&I;t%b?lIkI@c@hN?I)K zF8i?M&|rh?6jd>`TMC}k6bA~p5Q>`tY7*B`a3)Ur8j}HH253!&q!J`Unz%tgi2D1T zd(QgqmA36nr+;)t$JYJM_xm2_JKs6?arU0OKiaj)V;Djgk9e;jcf=o&kbM;5WV>V) z)-L=aBCZwh6h0tT_=`vhsa?}_Qn}XDRC->}IrwY$*g(4{A}gA{&4z`hIzm#mccnyB z)uvrRo7Gf^kOXMQSc6wf7Ic@aX!?kX;~7P@9a-8nDZ3_Rr|AV1n5Mda>>K~KD}UQP z5pd)qBx0jHUZK=w+4^E3!TOs4$$~~?Mbn#YSZJ#4eh+qx^M6`Yn#4BMUZuRes`{s? zVnxe9s=IAX%Rr)eAeAl-H4nA7HMgw^=QH6|vfuPi-P>;8Aw$x641r_J3-QM}KzZ!= z<2MZb@XObJ_T2JQ*;P+Hd)?6Z`>DSOfAk^yWj8FdN&LpwM)lMHH@$oj(1Pi(SX=?` zu7GDN;6oMgPzAiB0{*8JaGq{6#lN=#{s{08{@i6HfSLTfzXHC!0)B4=d_@KP!3y~P z3V5ml&e&&)zor6y5AZs%M2v-Yp(cbr9|h)X52t6F$R`WMR6-<&QU%eMEM)hRL!~d* zhe|FP9~j8=h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