|
91 | 91 | # the given configuration and HQL.
|
92 | 92 | my $RUNNER = HiveCLI->new();
|
93 | 93 |
|
| 94 | +use constant TRUE_VALUES => [ qw( 1 true yes on ) ]; |
| 95 | +use constant FALSE_VALUES => [ qw( 0 false no off ), '', undef ]; |
94 | 96 |
|
95 | 97 | # this is a stupid-simple web server running on AnyEvent. I chose it because
|
96 | 98 | # it needs to play nice with Hadoop::HiveCLI which also uses AnyEvent.
|
|
116 | 118 | return $req->respond( res_json_xx(400, 'query_id parameter required', {} ) );
|
117 | 119 | };
|
118 | 120 |
|
119 |
| - my $user_name = $req->parm('user_name') // do { |
120 |
| - return $req->respond( res_json_xx(400, 'user_name parameter required', {} ) ); |
121 |
| - }; |
122 |
| - # set the user to run the hive command as |
123 |
| - $hive_opts{user} = $user_name; |
124 |
| - |
125 | 121 | my $template_name = $req->parm('template_name') // do {
|
126 | 122 | return $req->respond( res_json_xx(400, 'template_name parameter required', {} ) );
|
127 | 123 | };
|
|
130 | 126 | return $req->respond( res_json_xx(400, 'hql parameter required', {} ) );
|
131 | 127 | };
|
132 | 128 |
|
| 129 | + # set the user to run the hive command as |
| 130 | + my $user_name = $hive_opts{user} = $req->parm('user_name') || $ENV{USER}; |
| 131 | + |
133 | 132 | # get the queue permissions of the user
|
134 |
| - my @queue_perms = capturex(qw(sudo -E -u), $user_name, which('hadoop'), qw(queue -showacls)); |
| 133 | + my @queue_perm_cmd = ( which('hadoop'), qw(queue -showacls) ); |
| 134 | + unshift @queue_perm_cmd, ( qw(sudo -E -u), $user_name ) |
| 135 | + if is_truthy( $CFG->{backend_use_sudo} ); |
| 136 | + my @queue_perms = capturex( @queue_perm_cmd ); |
135 | 137 |
|
136 | 138 | # set the queue if the user specified one
|
137 | 139 | if ( my $queue = $req->parm('queue') ) {
|
|
153 | 155 | if ( ! grep { /^\Q$queue\E\s+.*submit-job/ } @queue_perms ) {
|
154 | 156 | warn join " ",
|
155 | 157 | "User [$user_name] does not have permission to submit jobs in queue [$queue]",
|
156 |
| - #"which is set in the query. Running job as user [$ENV{USER}] until this is resolved.\n"; |
157 | 158 | "which is set in the query. Attempting to remove this line from the query...\n";
|
158 | 159 | #$hive_opts{user} = $ENV{USER};
|
159 | 160 | #last;
|
|
0 commit comments