Changeset 164 for trunk/src


Ignore:
Timestamp:
Feb 6, 2008, 10:31:00 PM (17 years ago)
Author:
katerina
Message:

Add 'closecommand' directive for external commands.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_extern.c

    r160 r164  
    10601060
    10611061  SL_RETURN (0, _("sh_ext_cleanup"));
     1062}
     1063
     1064/*
     1065 * -- explicitely close a command
     1066 */
     1067int sh_ext_close_command (const char * str)
     1068{
     1069  (void) str;
     1070  if (ext_coms == NULL || ext_failed == (-1))
     1071    return (-1);
     1072  ext_failed = (-1);
     1073  return 0;
    10621074}
    10631075
  • trunk/src/sh_readconf.c

    r160 r164  
    742742  { N_("opencommand"),     SH_SECTION_EXTERNAL, SH_SECTION_NONE, 
    743743    sh_ext_setcommand },
     744  { N_("closecommand"),    SH_SECTION_EXTERNAL, SH_SECTION_NONE, 
     745    sh_ext_close_command },
    744746  { N_("setcommandline"),  SH_SECTION_EXTERNAL, SH_SECTION_NONE, 
    745747    sh_ext_add_argv },
     
    11081110
    11091111static int sh_readconfig_line (char * line)
    1110 {   
    1111   char * c;
     1112{
     1113  char * key;
     1114  char * value;
    11121115  char * tmp;
    11131116  int    i;
     
    11171120  int    modnum, modkey;
    11181121#endif
     1122
     1123  static char  *dummy = N_("dummy");
     1124
     1125  static char  *closing[] = {
     1126    N_("closecommand"),
     1127    NULL
     1128  };
    11191129
    11201130  static char  *ident[] = {
     
    11571167  SL_ENTER(_("sh_readconf_line"));
    11581168
     1169  /* convert to lowercase                              */
     1170
     1171  tmp = line;
     1172  while (*tmp != '=' && *tmp != '\0')
     1173    {
     1174      *tmp = tolower( (int) *tmp);
     1175      ++tmp;
     1176    }
     1177
     1178  key = line;
     1179
    11591180  /* interpret line                                    */
    11601181
    1161   c = strchr(line, '=');
    1162   if (c == NULL || (*c) == '\0')
    1163     {
    1164       if (line != NULL)
     1182  value = strchr(line, '=');
     1183
     1184  if (value == NULL || (*value) == '\0')
     1185    {
     1186      if (key != NULL)
     1187        {
     1188          i = 0;
     1189          while (closing[i] != NULL)
     1190            {
     1191              if (sl_strncmp(key,_(closing[i]),sl_strlen(closing[i])-1) == 0)
     1192                {
     1193                  value = dummy;
     1194                  goto ok_novalue;
     1195                }
     1196              ++i;
     1197            }
     1198
     1199          TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"),
     1200                line));
     1201        }
     1202      SL_RETURN(good_opt, _("sh_readconf_line"));
     1203    }
     1204  else
     1205    ++value;
     1206
     1207  /* skip leading whitespace
     1208   */
     1209  while ((*value) == ' ' || (*value) == '\t')
     1210    ++value;
     1211
     1212  if ((*value) == '\0')     /* no value                    */
     1213    {
     1214      if (key != NULL)
    11651215        {
    11661216          TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"),
     
    11691219      SL_RETURN(good_opt, _("sh_readconf_line"));
    11701220    }
    1171   else
    1172     ++c;
    1173 
    1174   /* skip leading whitespace
    1175    */
    1176   while ((*c) == ' ' || (*c) == '\t')
    1177     ++c;
    1178 
    1179   if ((*c) == '\0')     /* no value                    */
    1180     {
    1181       if (line != NULL)
    1182         {
    1183           TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"),
    1184                 line));
    1185         }
    1186       SL_RETURN(good_opt, _("sh_readconf_line"));
    1187     }
    1188 
    1189   /* convert to lowercase                              */
    1190 
    1191   tmp = line;
    1192   while (*tmp != '=')
    1193     {
    1194       *tmp = tolower( (int) *tmp);
    1195       ++tmp;
    1196     }
     1221
     1222 ok_novalue:
    11971223
    11981224  if (!sl_is_suid())
     
    12101236               ++modkey)
    12111237            {
    1212               if (sl_strncmp (line,   
     1238              if (sl_strncmp (key,
    12131239                              _(modList[modnum].conf_table[modkey].the_opt),
    12141240                              sl_strlen(modList[modnum].conf_table[modkey].the_opt) ) == 0)
    12151241                {
    12161242                  good_opt = 0;
    1217                   if (0 != modList[modnum].conf_table[modkey].func(c))
     1243                  if (0 != modList[modnum].conf_table[modkey].func(value))
    12181244                    sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS,
    1219                                      _(modList[modnum].conf_table[modkey].the_opt), c);
     1245                                     _(modList[modnum].conf_table[modkey].the_opt), value);
    12201246                  if (!sl_is_suid())
    12211247                    {
     
    12371263      i = 0;
    12381264      while (ident[i] != NULL) {
    1239         if (sl_strncmp (line, _(ident[i]), sl_strlen(ident[i])-1) == 0)
     1265        if (sl_strncmp (key, _(ident[i]), sl_strlen(ident[i])-1) == 0)
    12401266          {
    12411267            good_opt = 0;
    1242             sh_error_set_iv (identnum[i], c);
     1268            sh_error_set_iv (identnum[i], value);
    12431269            break;
    12441270          }
     
    12531279          if ((ext_table[i].section == read_mode ||
    12541280               ext_table[i].alt_section == read_mode) &&
    1255               sl_strncmp (line, _(ext_table[i].optname),
     1281              sl_strncmp (key, _(ext_table[i].optname),
    12561282                          sl_strlen(ext_table[i].optname)) == 0)
    12571283            {
    12581284              good_opt = 0;
    1259               if (0 != ext_table[i].func (c))
     1285              if (0 != ext_table[i].func (value))
    12601286                sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS,
    1261                                  _(ext_table[i].optname), c);
     1287                                 _(ext_table[i].optname), value);
    12621288              break;
    12631289            }
Note: See TracChangeset for help on using the changeset viewer.