@@ -25,16 +25,9 @@ COMMAND_HISTORY_SERVER="history-server"
2525JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_RPC_ADDRESS:- $(hostname -f)}
2626CONF_FILE_DIR=" ${FLINK_HOME} /conf"
2727
28- drop_privs_cmd () {
29- if [ $( id -u) != 0 ]; then
30- # Don't need to drop privs if EUID != 0
31- return
32- elif [ -x /sbin/su-exec ]; then
33- # Alpine
34- echo su-exec flink
35- else
36- # Others
37- echo gosu flink
28+ check_priv_user () {
29+ if [ $( id -u) == 0 ]; then
30+ echo " WARNING: Running as root user is not recommended. Please use a non-root user to run Flink."
3831 fi
3932}
4033
@@ -146,6 +139,8 @@ maybe_enable_jemalloc() {
146139 fi
147140}
148141
142+ check_priv_user
143+
149144maybe_enable_jemalloc
150145
151146copy_plugins_if_required
@@ -163,28 +158,28 @@ elif [ "$1" = "jobmanager" ]; then
163158
164159 echo " Starting Job Manager"
165160
166- exec $( drop_privs_cmd ) " $FLINK_HOME /bin/jobmanager.sh" start-foreground " ${args[@]} "
161+ exec " $FLINK_HOME /bin/jobmanager.sh" start-foreground " ${args[@]} "
167162elif [ " $1 " = ${COMMAND_STANDALONE} ]; then
168163 args=(" ${args[@]: 1} " )
169164
170165 echo " Starting Job Manager"
171166
172- exec $( drop_privs_cmd ) " $FLINK_HOME /bin/standalone-job.sh" start-foreground " ${args[@]} "
167+ exec " $FLINK_HOME /bin/standalone-job.sh" start-foreground " ${args[@]} "
173168elif [ " $1 " = ${COMMAND_HISTORY_SERVER} ]; then
174169 args=(" ${args[@]: 1} " )
175170
176171 echo " Starting History Server"
177172
178- exec $( drop_privs_cmd ) " $FLINK_HOME /bin/historyserver.sh" start-foreground " ${args[@]} "
173+ exec " $FLINK_HOME /bin/historyserver.sh" start-foreground " ${args[@]} "
179174elif [ " $1 " = " taskmanager" ]; then
180175 args=(" ${args[@]: 1} " )
181176
182177 echo " Starting Task Manager"
183178
184- exec $( drop_privs_cmd ) " $FLINK_HOME /bin/taskmanager.sh" start-foreground " ${args[@]} "
179+ exec " $FLINK_HOME /bin/taskmanager.sh" start-foreground " ${args[@]} "
185180fi
186181
187182args=(" ${args[@]} " )
188183
189184# Running command in pass-through mode
190- exec $( drop_privs_cmd ) " ${args[@]} "
185+ exec " ${args[@]} "
0 commit comments