Re: [AMBER-Developers] AMBERHOME with spaces

From: Eric Pettersen <pett.cgl.ucsf.edu>
Date: Tue, 13 Jul 2021 13:13:40 -0700

Anyway, here's the patch as straight text, if the remailer doesn't mangle it...

--- AmberTools/src/antechamber/common.c 2020-04-27 18:19:42.000000000 -0700
+++ AmberTools/src/antechamber/common.c.new 2021-07-13 11:32:49.000000000 -0700
.. -21,14 +21,22 ..
    'for_system' indicates if the path will be used in a 'system'
    command and therefore needs quotes if there are spaces in the
    AMBERHOME variable.
- dac change: code to handle spaces in AMBERHOME is wrong! remove earlier refs to quote
  */
 size_t build_path(char *path, const char *subdir, const char *fname, size_t sizeof_path,
                   int for_system)
 {
     /* number of chars copied plus 1; on overflow > sizeof_path */
+ char *quote = NULL;
     size_t c = 1;
     path[0] = '\0';
+ if (for_system && index(amberhome, ' ') != NULL) {
+ if (index(amberhome, '"') == NULL)
+ quote = "\"";
+ else
+ quote = "'";
+ strncat(path, quote, sizeof_path - c);
+ c += 1;
+ }
 
     strncat(path, amberhome, sizeof_path - c);
     c += strlen(amberhome);
.. -36,6 +44,10 ..
     c += strlen(subdir);
     strncat(path, fname, sizeof_path - c);
     c += strlen(fname);
+ if (quote != NULL) {
+ strncat(path, quote, sizeof_path - c);
+ c += 1;
+ }
     if (c > sizeof_path) {
         eprintf("Insufficient string size.\n"
         "Increase MAXCHAR in define.h and rebuild.\n"


> On Jul 13, 2021, at 1:12 PM, Eric Pettersen <pett.cgl.ucsf.edu> wrote:
>
> Does the list strip attachments? The mail I originally sent had the attachment...
>
>> On Jul 13, 2021, at 1:09 PM, Eric Pettersen <pett.cgl.ucsf.edu> wrote:
>>
>> Hi All,
>> Somewhere between AmberTools 18 and 20, the code in antechamber that quoted executable paths with spaces in them before being sent to a system() call got removed. Consequently, antechamber can't execute its subprograms (e.g. bondtype) in such situations and bombs out (since the system() call interprets the path up to the first space as the "executable"). So antechamber will fail if AmberTools is installed into a folder/directory with a space anywhere in the path leading to it.
>> I have attached a patch file for AmberTools/src/antechamber/common.c that restores the quote-if-necessary functionality. I hope it can be incorporated, or some other code added that produces the same result.
>>
>> --Eric
>>
>> Eric Pettersen
>> UCSF Computer Graphics Lab
>>
>> _______________________________________________
>> AMBER-Developers mailing list
>> AMBER-Developers.ambermd.org
>> http://lists.ambermd.org/mailman/listinfo/amber-developers
>
>
> _______________________________________________
> AMBER-Developers mailing list
> AMBER-Developers.ambermd.org
> http://lists.ambermd.org/mailman/listinfo/amber-developers


_______________________________________________
AMBER-Developers mailing list
AMBER-Developers.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber-developers
Received on Tue Jul 13 2021 - 13:30:03 PDT
Custom Search