Subversion Repositories HelenOS

Rev

Rev 3767 | Rev 3813 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3767 Rev 3809
Line 70... Line 70...
70
    if (NULL == usr->line)
70
    if (NULL == usr->line)
71
        return CL_EFAIL;
71
        return CL_EFAIL;
72
 
72
 
73
    tmp = cli_strdup(usr->line);
73
    tmp = cli_strdup(usr->line);
74
 
74
 
75
    /* Break up what the user typed, space delimited */
-
 
76
 
-
 
77
    /* TODO: Protect things in quotes / ticks, expand wildcards */
-
 
78
    cmd[n] = cli_strtok(tmp, " ");
75
    cmd[n] = cli_strtok(tmp, " ");
79
    while (cmd[n] && n < WORD_MAX) {
76
    while (cmd[n] && n < WORD_MAX) {
80
        cmd[++n] = cli_strtok(NULL, " ");
77
        cmd[++n] = cli_strtok(NULL, " ");
81
    }
78
    }
82
 
79
 
Line 84... Line 81...
84
    if (NULL == cmd[0]) {
81
    if (NULL == cmd[0]) {
85
        rc = CL_ENOENT;
82
        rc = CL_ENOENT;
86
        goto finit;
83
        goto finit;
87
    }
84
    }
88
 
85
 
89
    /* Its a builtin command */
86
    /* Its a builtin command ? */
90
    if ((i = (is_builtin(cmd[0]))) > -1) {
87
    if ((i = (is_builtin(cmd[0]))) > -1) {
91
        /* Its not available in this mode, see what try_exec() thinks */
-
 
92
        if (builtin_is_restricted(i)) {
-
 
93
                rc = try_exec(cmd[0], cmd);
-
 
94
                if (rc)
-
 
95
                    /* No external matching it could be found, tell the
-
 
96
                     * user that the command does exist, but is not
-
 
97
                     * available in this mode. */
-
 
98
                    cli_restricted(cmd[0]);
-
 
99
                goto finit;
-
 
100
        }
-
 
101
        /* Its a builtin, its available, run it */
-
 
102
        rc = run_builtin(i, cmd, usr);
88
        rc = run_builtin(i, cmd, usr);
103
        goto finit;
89
        goto finit;
104
    /* We repeat the same dance for modules */
90
    /* Its a module ? */
105
    } else if ((i = (is_module(cmd[0]))) > -1) {
91
    } else if ((i = (is_module(cmd[0]))) > -1) {
106
        if (module_is_restricted(i)) {
-
 
107
            rc = try_exec(cmd[0], cmd);
-
 
108
            if (rc)
-
 
109
                cli_restricted(cmd[0]);
-
 
110
            goto finit;
-
 
111
        }
-
 
112
        rc = run_module(i, cmd);
92
        rc = run_module(i, cmd);
113
        goto finit;
93
        goto finit;
114
    } else {
-
 
115
        /* Its not a module or builtin, restricted or otherwise.
-
 
116
         * See what try_exec() thinks of it and just pass its return
-
 
117
         * value back to the caller */
-
 
118
        rc = try_exec(cmd[0], cmd);
-
 
119
        goto finit;
-
 
120
    }
94
    }
121
 
95
 
-
 
96
    /* See what try_exec thinks of it */
-
 
97
    rc = try_exec(cmd[0], cmd);
-
 
98
 
122
finit:
99
finit:
123
    if (NULL != usr->line) {
100
    if (NULL != usr->line) {
124
        free(usr->line);
101
        free(usr->line);
125
        usr->line = (char *) NULL;
102
        usr->line = (char *) NULL;
126
    }
103
    }