Subversion Repositories wimsdev

Rev

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

Rev 8185 Rev 8849
Line 28... Line 28...
28
{
28
{
29
    int i;
29
    int i;
30
    char c, *p1, *p2, *p3;
30
    char c, *p1, *p2, *p3;
31
    opt_class[0]=opt_module[0]=opt_session[0]=opt_user[0]=0;
31
    opt_class[0]=opt_module[0]=opt_session[0]=opt_user[0]=0;
32
    for(i=0, p1=find_word_start(textptr); *p1=='-'; p1=find_word_start(p2),i++) {
32
    for(i=0, p1=find_word_start(textptr); *p1=='-'; p1=find_word_start(p2),i++) {
33
        p1++; c=*p1++; p1=find_word_start(p1);
33
      p1++; c=*p1++; p1=find_word_start(p1);
34
        p2=find_word_end(p1); if(*p2) *p2++=0;
34
      p2=find_word_end(p1); if(*p2) *p2++=0;
35
        switch(c) {
35
      switch(c) {
36
            case 'c': {                 /* class */
36
          case 'c': {                  /* class */
37
                if(cwdtype!=dir_home) {
37
            if(cwdtype!=dir_home) {
38
                    sockerror(2,"option_conflict"); return -1;
38
                sockerror(2,"option_conflict"); return -1;
39
                }
39
            }
40
                if(strlen(p1)>=MAX_CLASSLEN || !myisdigit(*p1) ||
40
            if(strlen(p1)>=MAX_CLASSLEN || !myisdigit(*p1) ||
41
                   strstr(p1,"..")!=NULL) {
41
               strstr(p1,"..")!=NULL) {
42
                    sockerror(2,"illegal_fname %s",p1);
42
                sockerror(2,"illegal_fname %s",p1);
43
                    return -1;
43
                return -1;
44
                }
44
            }
45
                (void)chdir(classd); if(chdir(p1)<0) {
45
            (void)chdir(classd); if(chdir(p1)<0) {
46
                    sockerror(2,"bad_class %s",p1);
46
                sockerror(2,"bad_class %s",p1);
47
                    return -1;
47
                return -1;
48
                }
48
            }
49
                mystrncpy(opt_class,p1,sizeof(opt_class));
49
            mystrncpy(opt_class,p1,sizeof(opt_class));
50
                cwdtype=dir_class; break;
50
            cwdtype=dir_class; break;
51
            }
51
          }
52
            case 'm': {                 /* module */
52
          case 'm': {                  /* module */
53
                if(cwdtype!=dir_home) {
53
            if(cwdtype!=dir_home) {
54
                    sockerror(2,"option_conflict"); return -1;
54
                sockerror(2,"option_conflict"); return -1;
55
                }
55
            }
56
                if(strlen(p1)>MAX_FNAME || *p1=='/' || strstr(p1,"..")!=NULL) {
56
            if(strlen(p1)>MAX_FNAME || *p1=='/' || strstr(p1,"..")!=NULL) {
57
                    sockerror(2,"illegal_fname %s",p1);
57
                sockerror(2,"illegal_fname %s",p1);
58
                    return -1;
58
                return -1;
59
                }
59
            }
60
                (void)chdir(modd); if(chdir(p1)<0) {
60
            (void)chdir(modd); if(chdir(p1)<0) {
61
                    sockerror(2,"bad_module:%s",p1);
61
                sockerror(2,"bad_module:%s",p1);
62
                    return -1;
62
                return -1;
63
                }
63
            }
64
                mystrncpy(opt_module,p1,sizeof(opt_module));
64
            mystrncpy(opt_module,p1,sizeof(opt_module));
65
                cwdtype=dir_module; break;
65
            cwdtype=dir_module; break;
66
            }
66
          }
67
            case 's': {                 /* session */
67
          case 's': {                  /* session */
68
                if(cwdtype!=dir_home) {
68
            if(cwdtype!=dir_home) {
69
                    sockerror(2,"option_conflict"); return -1;
69
                sockerror(2,"option_conflict"); return -1;
70
                }
70
            }
71
                if(strlen(p1)>=MAX_CLASSLEN || *p1=='/' || strstr(p1,"..")!=NULL) {
71
            if(strlen(p1)>=MAX_CLASSLEN || *p1=='/' || strstr(p1,"..")!=NULL) {
72
                    sockerror(2,"illegal_fname:%s",p1);
72
                sockerror(2,"illegal_fname:%s",p1);
73
                    return -1;
73
                return -1;
74
                }
74
            }
75
                (void)chdir(sesd); if(chdir(p1)<0) {
75
            (void)chdir(sesd); if(chdir(p1)<0) {
76
                    sockerror(2,"bad_session:%s",p1);
76
                sockerror(2,"bad_session:%s",p1);
77
                    return -1;
77
                return -1;
78
                }
78
            }
79
                mystrncpy(opt_session,p1,sizeof(opt_session));
79
            mystrncpy(opt_session,p1,sizeof(opt_session));
80
                cwdtype=dir_session; break;
80
            cwdtype=dir_session; break;
81
            }
81
          }
82
            case 'u': {                 /* user definition */
82
          case 'u': {                  /* user definition */
83
                if(strchr(p1,'/')!=NULL) {
83
            if(strchr(p1,'/')!=NULL) {
84
                    sockerror(2,"illegal_fname %s",p1);
84
                sockerror(2,"illegal_fname %s",p1);
85
                    return -1;
85
                return -1;
86
                }
86
            }
87
                mystrncpy(opt_user,p1,sizeof(opt_user));
87
            mystrncpy(opt_user,p1,sizeof(opt_user));
88
                for(p3=strchr(opt_user,'.'); p3!=NULL; p3=strchr(p3,'.')) *p3++='@';
88
            for(p3=strchr(opt_user,'.'); p3!=NULL; p3=strchr(p3,'.')) *p3++='@';
89
                break;
89
            break;
90
            }
90
          }
91
            default: {
91
          default: {
92
                sockerror(2,"bad_option"); return -1;
92
            sockerror(2,"bad_option"); return -1;
93
            }
93
          }
94
        }
94
      }
95
    }
95
    }
96
    textptr=p1; return i;
96
    textptr=p1; return i;
97
}
97
}
98
 
98