Re: Setting a default location for files
Thomas Spahni <[email protected]> Wed, 12 Jan 2011 13:21:42 +0100 (CET)
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 11 Jan 2011, [email protected] wrote: > So, the good news is that the error is (sorta) reproduceable. > > The bad news is that case 3 above demonstrates that it's coming > in from exec() and not inside crm114, just as: > > http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Portability > > describes. Yep. It is a linux issue. Can't be fixed on the crm side except by adding a special routine to detect and parse the glued-together argument. > As an intermediate fix, if you are running a .sh file, and you > do NOT put #! at the start of the first line, then the behavior > seems to be correct. Will that fix it for you? I did try to replace the crm symbolic link with a shell wrapper script #!/bin/bash /usr/bin/crm114 -u /var/lib/crm114 but no luck. The only solution I came up with was the least desirable for me: to patch crm_main.c. The patch adds some conditional code to enable the definition of a default directory at compile time. It will change into this directory whenever crm is called with no -u argument. Here is the patch, but be aware that this is against GerH build 4560. --- src/crm_main.c.orig 2011-01-11 16:16:40.703963443 +0100 +++ src/crm_main.c 2011-01-11 18:37:31.251941503 +0100 @@ -79,9 +79,12 @@ int act_like_Bill = 0; - - - +// Hack by packager: remember if the user opts for a directory +#if defined (CRM_SET_DEFAULT_DIR) +int user_option_u_is_used = 0; +#define QUOTEME_(x) #x +#define QUOTEME(x) QUOTEME_(x) +#endif // The VHT (Variable Hash Table) VHT_CELL **vht = NULL; @@ -945,6 +948,12 @@ untrappableerror_ex(SRC_LOC(), "Sorry, couldn't chdir to '%s'; errno=%d(%s)\n", argv[i], errno, errno_descr(errno)); } +#if defined (CRM_SET_DEFAULT_DIR) + else + { + user_option_u_is_used = 1; + } +#endif } goto end_command_line_parse_loop; } @@ -1582,6 +1591,32 @@ } } + // Hack by packager: change to a default directory + // To enable this, compile with the following define: + // -DCRM_SET_DEFAULT_DIR=/some/dir/you/like +#if defined (CRM_SET_DEFAULT_DIR) + if (user_option_u_is_used == 0) + { + if (user_trace) + { + fprintf(stderr, "Setting default WD to " QUOTEME(CRM_SET_DEFAULT_DIR) "\n"); + } + + if (chdir(QUOTEME(CRM_SET_DEFAULT_DIR))) + { + untrappableerror("Couldn't change to compile enabled WD. Big problem!\n", ""); + } + else + { + if (user_trace) + { + fprintf(stderr, "Successfully changed to compile enabled directory " + QUOTEME(CRM_SET_DEFAULT_DIR) "\n"); + } + } + } +#endif + // open, stat and load the program file if (openbracket < 0) { </end of patch> This works just fine. Regards, Thomas ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl