Rev 3304 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3304 | Rev 3339 | ||
---|---|---|---|
Line 66... | Line 66... | ||
66 | return CL_EFAIL; |
66 | return CL_EFAIL; |
67 | 67 | ||
68 | tmp = cli_strdup(usr->line); |
68 | tmp = cli_strdup(usr->line); |
69 | 69 | ||
70 | /* Break up what the user typed, space delimited */ |
70 | /* Break up what the user typed, space delimited */ |
- | 71 | ||
- | 72 | /* TODO: Protect things in quotes / ticks, expand wildcards */ |
|
71 | cmd[n] = cli_strtok(tmp, " "); |
73 | cmd[n] = cli_strtok(tmp, " "); |
72 | while (cmd[n] && n < WORD_MAX) { |
74 | while (cmd[n] && n < WORD_MAX) { |
73 | cmd[++n] = cli_strtok(NULL, " "); |
75 | cmd[++n] = cli_strtok(NULL, " "); |
74 | } |
76 | } |
75 | 77 | ||
Line 77... | Line 79... | ||
77 | if (NULL == cmd[0]) { |
79 | if (NULL == cmd[0]) { |
78 | rc = CL_ENOENT; |
80 | rc = CL_ENOENT; |
79 | goto finit; |
81 | goto finit; |
80 | } |
82 | } |
81 | 83 | ||
82 | /* Check what kind of command argv[0] might be */ |
84 | /* Check what kind of command argv[0] might be, TODO: move this to |
- | 85 | * a function */ |
|
83 | if ((i = (is_builtin(cmd[0]))) > -1) { |
86 | if ((i = (is_builtin(cmd[0]))) > -1) { |
84 | /* Its a builtin */ |
- | |
85 | if (builtin_is_restricted(i)) { |
87 | if (builtin_is_restricted(i)) { |
86 | /* Try an external command matching argv[0] */ |
- | |
87 | rc = try_exec(cmd[0], cmd); |
88 | rc = try_exec(cmd[0], cmd); |
88 | if (rc) |
89 | if (rc) |
89 | cli_restricted(cmd[0]); |
90 | cli_restricted(cmd[0]); |
90 | goto finit; |
91 | goto finit; |
91 | } |
92 | } |
92 | rc = run_builtin(i, cmd, usr); |
93 | rc = run_builtin(i, cmd, usr); |
93 | goto finit; |
94 | goto finit; |
94 | } else if ((i = (is_module(cmd[0]))) > -1) { |
95 | } else if ((i = (is_module(cmd[0]))) > -1) { |
95 | /* Its a module, it can't modify cliuser_t */ |
- | |
96 | if (module_is_restricted(i)) { |
96 | if (module_is_restricted(i)) { |
97 | rc = try_exec(cmd[0], cmd); |
97 | rc = try_exec(cmd[0], cmd); |
98 | if (rc) |
98 | if (rc) |
99 | cli_restricted(cmd[0]); |
99 | cli_restricted(cmd[0]); |
100 | goto finit; |
100 | goto finit; |
101 | } |
101 | } |
102 | rc = run_module(i, cmd); |
102 | rc = run_module(i, cmd); |
103 | goto finit; |
103 | goto finit; |
104 | } else { |
104 | } else { |
105 | /* See what try_exec() thinks of it */ |
- | |
106 | rc = try_exec(cmd[0], cmd); |
105 | rc = try_exec(cmd[0], cmd); |
107 | goto finit; |
106 | goto finit; |
108 | } |
107 | } |
109 | 108 | ||
110 | finit: |
109 | finit: |
Line 154... | Line 153... | ||
154 | read_line(line, INPUT_MAX); |
153 | read_line(line, INPUT_MAX); |
155 | len = strlen(line); |
154 | len = strlen(line); |
156 | /* Make sure we don't have rubbish or a C/R happy user */ |
155 | /* Make sure we don't have rubbish or a C/R happy user */ |
157 | if (len == 0 || line[0] == '\n') |
156 | if (len == 0 || line[0] == '\n') |
158 | return; |
157 | return; |
159 | if (len == 1 && line[len-1] == '\n') |
- | |
160 | return; |
- | |
161 | usr->line = cli_strdup(line); |
158 | usr->line = cli_strdup(line); |
162 | 159 | ||
163 | return; |
160 | return; |
164 | } |
161 | } |
165 | 162 |