diff --git a/tecs/instr_hosts.c b/tecs/instr_hosts.c index 02bcad5..844bdaa 100644 --- a/tecs/instr_hosts.c +++ b/tecs/instr_hosts.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "myc_str.h" #include "myc_fortran.h" @@ -16,15 +17,15 @@ static Instrument list[]={ { "FOCUS", "lnsa16.psi.ch", 9753, "FOCUS" , 1}, { "TASP", "lnsa12.psi.ch", 9753, "TASP", 1}, { "TASP0", "lnsa09.psi.ch", 9753, NULL , 0}, - { "RITA", "rita2.psi.ch", 9753, NULL , 0}, - { "PREP", "lnsa01.psi.ch", 9753, NULL , 0}, - { "AREA", "lnsa01.psi.ch", 9751, NULL , 0}, - { "TEST", "lnsa15.psi.ch", 9753, "lnslib", 2} + { "RITA", "pc4345.psi.ch", 9753, NULL , 0}, + { "PREP", "lnsa15.psi.ch", 9753, "lnslib", 2}, + { "AREA", "lnsa15.psi.ch", 9751, "lnslib", 2}, + { "TEST", "lnsa15.psi.ch", 9755, "lnslib", 2} }; int InstrHost(char *input, char *instr, char *host, char *user, char *pcod , int instr_len, int host_len, int user_len, int pcod_len) { - char buf[256]; + char buf[256], *lnscode; int i, j; struct tm tim; time_t t; @@ -56,7 +57,12 @@ int InstrHost(char *input, char *instr, char *host, char *user, char *pcod } else if (list[j].cod == 2) { time(&t); tim=*localtime(&t); - sprintf(pcod, "%02dlns%d", tim.tm_year % 100, tim.tm_mon/6+1); + lnscode=getenv("LNSCODE"); + if (lnscode == NULL) { + sprintf(pcod, "%02dlns%d", tim.tm_year % 100, tim.tm_mon/6+1); + } else { + sprintf(pcod, "%02dlns%s", tim.tm_year % 100, lnscode); + } } else { str_ncpy(pcod, " ", pcod_len); } diff --git a/tecs/instr_hosts.h b/tecs/instr_hosts.h index d94cd2a..13dc308 100644 --- a/tecs/instr_hosts.h +++ b/tecs/instr_hosts.h @@ -1,5 +1,5 @@ -#ifndef _MYC_STR_H_ -#define _MYC_STR_H_ +#ifndef _INSTR_HOSTS_H_ +#define _INSTR_HOSTS_H_ int InstrHost(char *input, char *instr, char *host, char *user, char *pcod , int instr_len, int host_len, int user_len, int pcod_len); @@ -8,4 +8,4 @@ int InstrHost(char *input, char *instr, char *host, char *user, char *pcod output is: instrument name, host name, user name and pcod (the code needed to enter...) */ -#endif /* _MYC_STR_H_ */ +#endif /* _INSTR_HOSTS_H_ */ diff --git a/tecs/rstart.c b/tecs/rstart.c index c858af6..3cfadb1 100644 --- a/tecs/rstart.c +++ b/tecs/rstart.c @@ -4,15 +4,32 @@ #include #include #include +#include #include "myc_str.h" #include "instr_hosts.h" int rexec(char **host, int port, char *user, char *passwd, char *command, int *err_file_desc); +char *secure_arg(char *cmd, int size, char *arg) { + int i; +/* make sure that argument is a harmless identifier and no hacker code */ + for (i=0; i