Ticket #1: 6

File 6, 7.8 KB (added by dlove, 9 years ago)
Line 
1Index: clients/common/read_defaults.c
2===================================================================
3RCS file: /usr/local/tigris/data/helm/cvs/repository/gridengine/source/clients/common/read_defaults.c,v
4retrieving revision 1.3
5diff -u -u -r1.3 read_defaults.c
6--- clients/common/read_defaults.c      2001/12/17 10:21:05     1.3
7+++ clients/common/read_defaults.c      2002/03/21 12:06:01
8@@ -65,6 +65,7 @@
9 *     into an options list.
10 *
11 *  INPUTS
12+*     char *cmd        - the name of the command being run
13 *     lList **pcmdline - pointer to SPA_Type list, if list is NULL, it is
14 *                        created if the files contain any options
15 *     char **envp      - environment pointer
16@@ -87,7 +88,7 @@
17 *
18 *     problem: make user a parameter?
19 *******************************************************************************/
20-lList *get_all_defaults_files(lList **pcmdline, char **envp)
21+lList *get_all_defaults_files(char *cmd, lList **pcmdline, char **envp)
22 {
23    lList *answer = NULL;
24    lList *alp;
25@@ -95,18 +96,25 @@
26    struct passwd *pwd;
27    char str[256 + 1];
28    char cwd[SGE_PATH_MAX + 1];
29+   char *p;
30    char **pstr;
31    char **ppstr;
32    SGE_STRUCT_STAT buf;
33+   int cmdlen;
34    int do_exit = 0;
35   
36    DENTER(TOP_LAYER, "get_all_defaults_files");
37 
38+   cmdlen = cmd ? strlen(cmd) : 0;
39+
40    /* the sge root defaults file */
41   
42    def_files[0] = malloc(strlen(path.cell_root) +
43-                         strlen(SGE_COMMON_DEF_REQ_FILE) + 2);
44-   sprintf(def_files[0], "%s/%s", path.cell_root, SGE_COMMON_DEF_REQ_FILE);
45+                         strlen(SGE_COMMON_DEF_REQ_FILE) + cmdlen + 3);
46+   sprintf(def_files[0], "%s/%s.%s",
47+           path.cell_root, SGE_COMMON_DEF_REQ_FILE, cmd);
48+   if (!sge_is_file(def_files[0]))
49+      sprintf(def_files[0], "%s/%s", path.cell_root, SGE_COMMON_DEF_REQ_FILE);
50 
51    /*
52     * the defaults file in the user's home directory
53@@ -124,22 +132,21 @@
54    }
55 
56    def_files[1] = malloc(strlen(pwd->pw_dir) +
57-                         strlen(SGE_HOME_DEF_REQ_FILE) + 2);
58+                         strlen(SGE_HOME_DEF_REQ_FILE) + cmdlen + 3);
59    strcpy(def_files[1], pwd->pw_dir);
60-   if (*def_files[1] && (def_files[1][strlen(def_files[1]) - 1] != '/')) {
61-      strcat(def_files[1], "/");
62-   }
63-   strcat(def_files[1], SGE_HOME_DEF_REQ_FILE);
64+   p = def_files[1] + strlen(def_files[1]);
65+   if (*def_files[1] && (p[-1] != '/')) {
66+      (p++)[0] = '/';
67+   }
68+   sprintf(p, "%s.%s", SGE_HOME_DEF_REQ_FILE, cmd);
69+   if (!sge_is_file(def_files[1]))
70+      p[sizeof(SGE_HOME_DEF_REQ_FILE)-1] = '\0';
71 
72    if (!sge_is_file(def_files[1])) {
73-      strcpy(def_files[1], pwd->pw_dir);
74-      if (*def_files[1] && (def_files[1][strlen(def_files[1]) - 1] != '/')) {
75-         strcat(def_files[1], "/");
76-      }
77       if (feature_is_enabled(FEATURE_SGEEE)) {
78-         strcat(def_files[1], GRD_HOME_DEF_REQ_FILE);
79+         strcpy(p, GRD_HOME_DEF_REQ_FILE);
80       } else {
81-         strcat(def_files[1], COD_HOME_DEF_REQ_FILE);
82+         strcpy(p, COD_HOME_DEF_REQ_FILE);
83       }
84    }
85 
86@@ -152,21 +159,21 @@
87       return answer;
88    }
89   
90-   def_files[2] = malloc(strlen(cwd) + strlen(SGE_HOME_DEF_REQ_FILE) + 2);
91+   def_files[2] = malloc(strlen(cwd) + strlen(SGE_HOME_DEF_REQ_FILE) + cmdlen + 3);
92    strcpy(def_files[2], cwd);
93-   if (*def_files[2] && (def_files[2][strlen(def_files[2]) - 1] != '/')) {
94-      strcat(def_files[2], "/");
95-   }
96-   strcat(def_files[2], SGE_HOME_DEF_REQ_FILE);
97+   p = def_files[2] + strlen(def_files[2]);
98+   if (*def_files[2] && (p[-1] != '/')) {
99+      (p++)[0] = '/';
100+   }
101+   sprintf(p, "%s.%s", SGE_HOME_DEF_REQ_FILE, cmd);
102+   if (!sge_is_file(def_files[2]))
103+      p[sizeof(SGE_HOME_DEF_REQ_FILE)-1] = '\0';
104+
105    if (!sge_is_file(def_files[2])) {
106-      strcpy(def_files[2], cwd);
107-      if (*def_files[2] && (def_files[2][strlen(def_files[2]) - 1] != '/')) {
108-         strcat(def_files[2], "/");
109-      }
110       if (feature_is_enabled(FEATURE_SGEEE)) {
111-         strcat(def_files[2], GRD_HOME_DEF_REQ_FILE);
112+         strcpy(p, GRD_HOME_DEF_REQ_FILE);
113       } else {
114-         strcat(def_files[2], COD_HOME_DEF_REQ_FILE);
115+         strcpy(p, COD_HOME_DEF_REQ_FILE);
116       }
117    }
118 
119Index: clients/common/read_defaults.h
120===================================================================
121RCS file: /usr/local/tigris/data/helm/cvs/repository/gridengine/source/clients/common/read_defaults.h,v
122retrieving revision 1.3
123diff -u -u -r1.3 read_defaults.h
124--- clients/common/read_defaults.h      2001/12/17 10:21:05     1.3
125+++ clients/common/read_defaults.h      2002/03/21 12:06:01
126@@ -38,7 +38,7 @@
127 #define COD_HOME_DEF_REQ_FILE   ".cod_request"
128 #define GRD_HOME_DEF_REQ_FILE   ".grd_request"
129 
130-lList *get_all_defaults_files(lList **pcmdline, char **envp);
131+lList *get_all_defaults_files(char *cmd, lList **pcmdline, char **envp);
132 
133 #endif /* __READ_DEFAULTS_H */
134 
135Index: clients/qmon/qmon_submit.c
136===================================================================
137RCS file: /usr/local/tigris/data/helm/cvs/repository/gridengine/source/clients/qmon/qmon_submit.c,v
138retrieving revision 1.14.2.3
139diff -u -u -r1.14.2.3 qmon_submit.c
140--- clients/qmon/qmon_submit.c  2002/03/18 09:22:47     1.14.2.3
141+++ clients/qmon/qmon_submit.c  2002/03/21 12:06:02
142@@ -1491,11 +1491,11 @@
143       /*
144       ** first of all read the default files
145       ** this is a three stage process
146-      ** $SGE_ROOT/sge_request
147-      ** $HOME/.sge_request
148-      ** ./.sge_request
149+      ** $SGE_ROOT/sge_request[.qsub]
150+      ** $HOME/.sge_request[.qsub]
151+      ** ./.sge_request[.qsub]
152       */
153-      alp = get_all_defaults_files(&cmdline, environ);
154+      alp = get_all_defaults_files("qsub", &cmdline, environ);
155 
156       if (alp) {
157          if (qmonMessageBox(w, alp, 0) == -1) {
158Index: clients/qsh/qsh.c
159===================================================================
160RCS file: /usr/local/tigris/data/helm/cvs/repository/gridengine/source/clients/qsh/qsh.c,v
161retrieving revision 1.17.2.1
162diff -u -u -r1.17.2.1 qsh.c
163--- clients/qsh/qsh.c   2002/02/26 13:49:49     1.17.2.1
164+++ clients/qsh/qsh.c   2002/03/21 12:06:02
165@@ -1340,6 +1340,7 @@
166 int argc,
167 char **argv
168 ) {
169+   char *cmd;
170    u_long32 my_who = QSH;
171    lList *opts_cmdline = NULL;
172    lList *opts_defaults = NULL;
173@@ -1380,14 +1381,16 @@
174 
175    DENTER_MAIN(TOP_LAYER, "qsh");
176 
177+   cmd = sge_basename(argv[0], '/');
178+
179    /*
180    ** get command name: qlogin, qrsh or qsh
181    */
182-   if(!strcmp(sge_basename(argv[0], '/'), "qlogin")) {
183+   if(!strcmp(cmd, "qlogin")) {
184       is_qlogin = 1;
185       my_who = QLOGIN;
186    } else {
187-      if(!strcmp(sge_basename(argv[0], '/'), "qrsh")) {
188+      if(!strcmp(cmd, "qrsh")) {
189          is_qlogin = 1;
190          is_rsh    = 1;
191          my_who = QRSH;
192@@ -1422,7 +1425,7 @@
193    /*
194    ** read switches from the various defaults files
195    */
196-   alp = get_all_defaults_files(&opts_defaults, environ);
197+   alp = get_all_defaults_files(cmd, &opts_defaults, environ);
198    do_exit = parse_result_list(alp, &alp_error);
199    lFreeList(alp);
200 
201Index: clients/qsub/qsub.c
202===================================================================
203RCS file: /usr/local/tigris/data/helm/cvs/repository/gridengine/source/clients/qsub/qsub.c,v
204retrieving revision 1.6
205diff -u -u -r1.6 qsub.c
206--- clients/qsub/qsub.c 2002/01/23 19:36:16     1.6
207+++ clients/qsub/qsub.c 2002/03/21 12:06:02
208@@ -74,6 +74,7 @@
209 int argc,
210 char **argv
211 ) {
212+   char *cmd;
213    lList *opts_cmdline = NULL;
214    lList *opts_defaults = NULL;
215    lList *opts_scriptfile = NULL;
216@@ -95,6 +96,8 @@
217 
218    DENTER_MAIN(TOP_LAYER, "qsub");
219 
220+   cmd = sge_basename(argv[0], '/');
221+
222    sge_gdi_param(SET_MEWHO, QSUB, NULL);
223 /*    sge_gdi_param(SET_ISALIVE, 1, NULL); */
224    if ((cl_err = sge_gdi_setup(prognames[QSUB]))) {
225@@ -113,7 +116,7 @@
226    /*
227    ** read switches from the various defaults files
228    */
229-   alp = get_all_defaults_files(&opts_defaults, environ);
230+   alp = get_all_defaults_files(cmd, &opts_defaults, environ);
231    for_each(aep, alp) {
232       const char *s;
233