updated host list M.Z.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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);
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
@ -4,15 +4,32 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include <ctype.h>
|
||||
#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<size-strlen(cmd)-2; i++) {
|
||||
if (arg[i]=='\0') { /* end of arg reached */
|
||||
strcat(cmd, " ");
|
||||
strcat(cmd, arg);
|
||||
return cmd;
|
||||
}
|
||||
if (! isalnum(arg[i]) && arg[i] != '_') {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int port, i, j, l, fd;
|
||||
char inst[32], cmd[256], host[256], user[64], pcod[64];
|
||||
char *hostp;
|
||||
char *hostp, *arg;
|
||||
struct tm tim;
|
||||
time_t t;
|
||||
|
||||
@ -32,10 +49,23 @@ int main(int argc, char *argv[]) {
|
||||
str_copy(cmd, "");
|
||||
for (i=2; i<argc; i++) {
|
||||
if (0==strcmp(argv[i], "sics")) {
|
||||
str_append(cmd, "bin/startsics\n");
|
||||
if (i<argc) {
|
||||
i++; arg=argv[i];
|
||||
} else {
|
||||
arg="";
|
||||
}
|
||||
str_append(cmd, "bin/startsics");
|
||||
secure_arg(cmd, sizeof(cmd), arg);
|
||||
str_append(cmd, "\n");
|
||||
} else if (0==strcmp(argv[i], "tecs")) {
|
||||
if (i<argc) i++; /* skip argument */
|
||||
str_append(cmd, "bin/startecs\n");
|
||||
if (i<argc) {
|
||||
i++; arg=argv[i];
|
||||
} else {
|
||||
arg="";
|
||||
}
|
||||
str_append(cmd, "bin/startecs");
|
||||
secure_arg(cmd, sizeof(cmd), arg);
|
||||
str_append(cmd, "\n");
|
||||
} else {
|
||||
printf("unknown server %s\n", argv[i]);
|
||||
return 0;
|
||||
@ -47,6 +77,7 @@ int main(int argc, char *argv[]) {
|
||||
if (fd<0) {
|
||||
perror("rexec"); return -1;
|
||||
}
|
||||
puts(cmd);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user