273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
}
/* If iTruth<0 then guess as to whether or not a PATH= argument is required
** when using ssh to run fossil on a remote machine name zHostname.
**
** If iTruth is 1 or 0 then that means that the PATH= is or is not required,
** respectively. Record this fact for future reference.
*/
int ssh_needs_path_argument(const char *zHostname, int iTruth){
int ans = 0; /* Default to "no" */
char *z = mprintf("use-path-for-ssh:%s", zHostname);
if( iTruth<0 ){
if( db_get_boolean(z/*works-like:"x"*/, 0) ) ans = 1;
}else if( iTruth ){
ans = 1;
db_set(z/*works-like:"x"*/, "1", 0);
}else{
db_unset(z/*works-like:"x"*/, 0);
}
fossil_free(z);
return ans;
}
/* Add an approprate PATH= argument to the SSH command under construction
** in pCmd.
*/
void ssh_add_path_argument(Blob *pCmd){
blob_append_escaped_arg(pCmd,
"PATH=$HOME/bin:/usr/local/bin:/opt/homebrew/bin:$PATH", 1);
|
>
>
>
>
>
>
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
}
/* If iTruth<0 then guess as to whether or not a PATH= argument is required
** when using ssh to run fossil on a remote machine name zHostname.
**
** If iTruth is 1 or 0 then that means that the PATH= is or is not required,
** respectively. Record this fact for future reference.
**
** If iTruth is 99 or more, then toggle the truth value.
*/
int ssh_needs_path_argument(const char *zHostname, int iTruth){
int ans = 0; /* Default to "no" */
char *z = mprintf("use-path-for-ssh:%s", zHostname);
if( iTruth<0 ){
if( db_get_boolean(z/*works-like:"x"*/, 0) ) ans = 1;
}else{
if( iTruth>=99 ){
iTruth = !db_get_boolean(z/*works-like:"x"*/, 0);
}
if( iTruth ){
ans = 1;
db_set(z/*works-like:"x"*/, "1", 0);
}else{
db_unset(z/*works-like:"x"*/, 0);
}
}
fossil_free(z);
return ans;
}
/*
** COMMAND: test-ssh-needs-path
**
** Usage: fossil test-ssh-needs-path HOSTNAME ?BOOLEAN?
**
** With one argument, show whether or not the PATH= argument is included
** by default for HOSTNAME. If the second argument is a boolean, then
** change the value.
**
** With no arguments, show all hosts for which ssh-needs-path is true.
*/
void test_ssh_needs_path(void){
db_find_and_open_repository(0,0);
if( g.argc>=3 ){
const char *zHost = g.argv[2];
int a = -1;
int rc;
if( g.argc>=4 ) a = is_truth(g.argv[3]);
rc = ssh_needs_path_argument(zHost, a);
fossil_print("%-20s %s\n", zHost, rc ? "yes" : "no");
}else{
Stmt s;
db_prepare(&s, "SELECT substr(name,18) FROM config"
" WHERE name GLOB 'use-path-for-ssh:*'");
while( db_step(&s)==SQLITE_ROW ){
const char *zHost = db_column_text(&s,0);
fossil_print("%-20s yes\n", zHost);
}
db_finalize(&s);
}
}
/* Add an approprate PATH= argument to the SSH command under construction
** in pCmd.
*/
void ssh_add_path_argument(Blob *pCmd){
blob_append_escaped_arg(pCmd,
"PATH=$HOME/bin:/usr/local/bin:/opt/homebrew/bin:$PATH", 1);
|