| | 609 | if (cmd->args[0][0] != '/') { |
|---|
| | 610 | if ((cp=FindOpt(cmd, "paths")) == NULL) |
|---|
| | 611 | return logger(LOG_ERR | LOG_PRINT, "No path nor absolute command. Access denied"); |
|---|
| | 612 | else { |
|---|
| | 613 | new_name=NULL; |
|---|
| | 614 | for (cp = GetField(cp, str, MAXSTRLEN - 1); cp != NULL; cp = GetField(cp, str, MAXSTRLEN - 1)) { |
|---|
| | 615 | if (*str != '/') /* Absolute path required */ |
|---|
| | 616 | continue; |
|---|
| | 617 | |
|---|
| | 618 | if (strlen(str)+strlen(cmd->args[0])+1 >= MAXSTRLEN - 1) |
|---|
| | 619 | continue; /* Pathname too long */ |
|---|
| | 620 | |
|---|
| | 621 | new_name=malloc(strlen(str)+strlen(cmd->args[0])+2); |
|---|
| | 622 | strcpy(new_name,str); |
|---|
| | 623 | strcat(new_name,"/"); |
|---|
| | 624 | strcat(new_name,cmd->args[0]); |
|---|
| | 625 | if (access(new_name,F_OK) != 0) |
|---|
| | 626 | new_name=NULL; |
|---|
| | 627 | else |
|---|
| | 628 | break; /* A path candidate is found */ |
|---|
| | 629 | } |
|---|
| | 630 | } |
|---|
| | 631 | if (new_name == NULL) |
|---|
| | 632 | return logger(LOG_ERR | LOG_PRINT, "No valid pathname found. Access denied"); |
|---|
| | 633 | |
|---|
| | 634 | free(cmd->args[0]); |
|---|
| | 635 | cmd->args[0]=new_name; |
|---|
| | 636 | } |
|---|
| | 637 | |
|---|