- Timestamp:
- Feb 3, 2009, 8:45:50 PM (16 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_extern.c
r174 r211 31 31 * for debugging 32 32 */ 33 #if 034 #define PDGBFILE "/ pdbg."33 #if 1 34 #define PDGBFILE "/home/rainer/PROJECTS/samhain/devel/pdbg." 35 35 #endif 36 36 … … 532 532 SL_ENTER(_("sh_ext_pclose")); 533 533 534 PDBG C_OPEN;534 PDBG_OPEN; 535 535 PDBG_S(" -> pclose"); 536 536 (void) fflush(task->pipe); … … 773 773 } 774 774 775 /* Execute command, return first line of output 776 * ifconfig | grep -1 lo | tail -n 1 | sed s/.*inet addr:\([0-9.]*\)\(.*\)/\1/ 777 */ 778 char * sh_ext_popen_str (char * command) 779 { 780 sh_tas_t task; 781 struct sigaction new_act; 782 struct sigaction old_act; 783 char dir[SH_PATHBUF]; 784 char * p; 785 char * out = NULL; 786 int status; 787 788 SL_ENTER(_("sh_ext_popen_str")); 789 790 sh_ext_tas_init(&task); 791 792 (void) sh_ext_tas_add_envv (&task, _("SHELL"), 793 _("/bin/sh")); 794 (void) sh_ext_tas_add_envv (&task, _("PATH"), 795 _("/sbin:/bin:/usr/sbin:/usr/bin:/usr/ucb")); 796 (void) sh_ext_tas_add_envv (&task, _("IFS"), " \n\t"); 797 if (sh.timezone != NULL) 798 { 799 (void) sh_ext_tas_add_envv(&task, "TZ", sh.timezone); 800 } 801 802 sh_ext_tas_command(&task, _("/bin/sh")); 803 804 (void) sh_ext_tas_add_argv(&task, _("/bin/sh")); 805 (void) sh_ext_tas_add_argv(&task, _("-c")); 806 (void) sh_ext_tas_add_argv(&task, command); 807 808 task.rw = 'r'; 809 task.fork_twice = S_FALSE; 810 811 status = sh_ext_popen(&task); 812 813 if (status != 0) 814 { 815 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN, 816 _("Could not open pipe"), _("sh_ext_popen_str")); 817 SL_RETURN ((NULL), _("sh_ext_popen_str")); 818 } 819 820 /* ignore SIGPIPE (instead get EPIPE if connection is closed) 821 */ 822 new_act.sa_handler = SIG_IGN; 823 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act); 824 825 /* read from the open pipe 826 */ 827 if (task.pipe != NULL) 828 { 829 int try = 1200; /* 1000 * 0.1 = 120 sec */ 830 sh_string * s = sh_string_new(0); 831 do { 832 sh_string_read(s, task.pipe, 0); 833 if (sh_string_len(s) == 0) 834 { 835 --try; retry_msleep(0, 100); 836 } 837 } while (sh_string_len(s) == 0 && try != 0); 838 839 if (sh_string_len(s) == 0) 840 { 841 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN, 842 _("No output from command"), _("sh_ext_popen_str")); 843 } 844 845 out = sh_util_strdup(sh_string_str(s)); 846 sh_string_destroy(&s); 847 } 848 849 /* restore old signal handler 850 */ 851 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &old_act, NULL); 852 853 /* close pipe and return exit status 854 */ 855 (void) sh_ext_pclose(&task); 856 sh_ext_tas_free (&task); 857 SL_RETURN ((out), _("sh_ext_popen_str")); 858 } 859 860 861 775 862 776 863 /* --------------- EXTERN STUFF ------------------- */ … … 1141 1228 (void) sh_ext_add_envv (_("HOME"), p); 1142 1229 (void) sh_ext_add_envv (_("SHELL"), _("/bin/sh")); 1143 (void) sh_ext_add_envv (_("PATH"), _("/sbin:/usr/sbin:/bin:/usr/bin")); 1230 (void) sh_ext_add_envv (_("PATH"), _("/sbin:/bin:/usr/sbin:/usr/bin")); 1231 (void) sh_ext_add_envv (_("IFS"), " \n\t"); 1144 1232 i = (p == NULL ? (-1) : 0); 1145 1233 SL_RETURN(i, _("sh_ext_add_default")); -
trunk/src/sh_readconf.c
r205 r211 135 135 { NULL, SH_SECTION_NONE} 136 136 }; 137 138 static char * sh_readconf_expand_value (const char * str) 139 { 140 char * tmp = (char*)str; 141 char * out; 142 143 while (tmp && isspace((int)*tmp)) ++tmp; 144 145 if (tmp[0] == '$' && tmp[1] == '(') 146 { 147 size_t len = strlen(tmp); 148 while (isspace((int) tmp[len-1])) { tmp[len-1] = '\0'; --len; } 149 if (tmp[len-1] == ')') 150 { 151 tmp[len-1] = '\0'; 152 out = sh_ext_popen_str(&tmp[2]); 153 return out; 154 } 155 } 156 return sh_util_strdup(str); 157 } 137 158 138 159 enum { … … 1297 1318 } 1298 1319 1320 /* Expand shell expressions. This return allocated memory which we must free. 1321 */ 1322 value = sh_readconf_expand_value(value); 1323 1324 if (!value || (*value) == '\0') 1325 { 1326 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: empty after shell expansion: %s>\n"), 1327 line)); 1328 SL_RETURN(good_opt, _("sh_readconf_line")); 1329 } 1299 1330 1300 1331 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) … … 1362 1393 } 1363 1394 1395 SH_FREE((char*)value); 1396 1364 1397 SL_RETURN(good_opt, _("sh_readconf_line")); 1365 1398 } -
trunk/src/trustfile.c
r192 r211 827 827 /* smack on the /../ 828 828 */ 829 t_const = "/../"; 829 t_const = "/../"; t = (char *)t_const; 830 830 while(*t && b < end) 831 *b++ = *t _const++;831 *b++ = *t++; 832 832 833 833 /* append the symlink referent
Note:
See TracChangeset
for help on using the changeset viewer.