|
17 | 17 | *under the License. |
18 | 18 |
|
19 | 19 |
|
20 | | -
|
21 | | -
|
22 | 20 | ####################################################################################### |
23 | 21 | Author: NerdOfCode |
24 | 22 | Tested on: Ubuntu Server 16.04 |
25 | 23 | Status: Working --> ^^^ |
26 | 24 | License: Apache-2.0 |
27 | | - Updated on: 9/29/18 |
| 25 | + Updated on: 10/28/18 |
28 | 26 | ####################################################################################### |
29 | 27 |
|
30 | 28 | ######################################################### |
@@ -83,10 +81,10 @@ int main ( int argc, char argv[64] ){ |
83 | 81 | //Test if user is allowed to use pwd and if allowed show the working directory |
84 | 82 | //Also test if user is allowed to use hostname and whomai |
85 | 83 | char *pwd_test; |
86 | | - int return_pwd_test_value; |
| 84 | + short int return_pwd_test_value; |
87 | 85 |
|
88 | 86 | char *whoami_test; |
89 | | - int return_whoami_test_value; |
| 87 | + short int return_whoami_test_value; |
90 | 88 |
|
91 | 89 | pwd_test = malloc(64 * sizeof(char)); |
92 | 90 | strcat(pwd_test,CMD_BIN); |
@@ -162,8 +160,8 @@ int main ( int argc, char argv[64] ){ |
162 | 160 | memset(pwd_test,0,sizeof(pwd_test)); |
163 | 161 | memset(whoami_test,0,sizeof(whoami_test)); |
164 | 162 |
|
165 | | - //TODO |
166 | | - log_command(input); |
| 163 | + if(LOGGING) |
| 164 | + log_command(input); |
167 | 165 |
|
168 | 166 | //Not a good idea for case specific things, will need to make its own function for better use |
169 | 167 |
|
@@ -203,9 +201,17 @@ void change_to_home_dir( void ){ |
203 | 201 | //TODO |
204 | 202 | //Create a better method for the following |
205 | 203 | //Assume users directory is /home/logged_in_user |
| 204 | + |
| 205 | + //For chdir() return code |
| 206 | + short int return_status = 0; |
| 207 | + |
206 | 208 | char current_user_home[64] = "/home/"; |
207 | 209 | strcat(current_user_home,logged_in_user); |
208 | | - chdir(current_user_home); |
| 210 | + return_status = chdir(current_user_home); |
| 211 | + |
| 212 | + if(return_status != 0) |
| 213 | + puts(RED_TEXT"Error: 1005"RESET); |
| 214 | + |
209 | 215 | } |
210 | 216 |
|
211 | 217 | int start_up( void ){ |
@@ -289,9 +295,8 @@ void commands(){ |
289 | 295 | puts("flags"); |
290 | 296 | puts("history"); |
291 | 297 | puts("rm"); |
292 | | - puts("time"); |
| 298 | + puts("date"); |
293 | 299 | puts("mkdir"); |
294 | | - puts(""); |
295 | 300 |
|
296 | 301 | } |
297 | 302 |
|
|
0 commit comments