summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJefferson Delfes <jefferson.delfes@gmail.com>2013-12-02 12:04:13 -0400
committerJefferson Delfes <jefferson.delfes@gmail.com>2013-12-02 13:14:18 -0400
commit382001f95f52e9ce51e0060efe9066ea3c282b4f (patch)
tree943804977ffc670d5632dc45f42177c738a5f0b8
parentb306059649ec817e5c80aaba767721944cd2e998 (diff)
Check if it's running as root user
Trying to enable bluetooth module without root permission, give us some weird issues, it does not work. So we need to check it before doing anything.
-rw-r--r--btctl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/btctl.c b/btctl.c
index 609df44..6ae0ec3 100644
--- a/btctl.c
+++ b/btctl.c
@@ -2059,6 +2059,13 @@ const char *tab_completer_cb(char *line, int pos) {
}
int main(int argc, char *argv[]) {
+
+ /* check if I am root */
+ if (getuid() != 0) {
+ printf("This software requires root access\n");
+ return 1;
+ }
+
rl_init(cmd_process);
change_prompt_state(NORMAL_PSTATE);
rl_set_tab_completer(tab_completer_cb);