4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
6 * Contact: Kidong Kim <kd0228.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include <sys/types.h>
28 #include "privilege-control.h"
30 void print_usage(void)
32 printf("%s", "Usage: slp-su [PKG_NAME]\n\n");
33 printf("%s", "Execute new shell which be belonged to user related with PKG_NAME\n\n");
36 int main(int argc, char* argv[])
43 fprintf(stderr, "%s", "[ERR] Check your argument.\n\n");
53 if(set_app_privilege(argv[1], NULL, NULL) == 0) // success
55 fprintf(stderr, "%s", "[LOG] Success to execute set_privilege()\n");
59 fprintf(stderr, "%s", "[ERR] Fail to execute set_privilege()\n");
64 if(buf == NULL) // fail
66 fprintf(stderr, "%s", "[ERR] Fail to execute getenv()\n");
71 fprintf(stderr, "%s: [%s]%s", "[LOG] HOME", buf, "\n");
74 if(chdir(buf) == 0) // success
76 fprintf(stderr, "%s", "[LOG] Success to change working directory\n");
80 fprintf(stderr, "%s", "[ERR] Fail to execute chdir()\n");
84 execl("/bin/sh", "/bin/sh", NULL);
89 fprintf(stderr, "%s", "[ERR] Fail to execute fork()\n");
96 fprintf(stderr, "%s", "[LOG] Parent end\n");