Trouble building PInfo

I am having trouble building Pinfo.

My configure line looks like this:
./configure –prefix=/usr/mylocal –with-curses=/usr/mylocal

The error message I get is
checking location of curses.h file… /usr/mylocal/include/ncurses/ncurses.h
checking if curses is usable… no
configure: error: Curses not found. You need curses to compile pinfo

However, it manages to locate ncurses.h as you can tell from this excerpt from config.log, but then claims the routines are missing. If I try building conftest.c myself with –save-temps and then look at conftest.i, each routine is defined as “extern WINDOW *”, for example “extern WINDOW * stdscr;”. There is also a “typedef struct _win_st WINDOW;” statement to define WINDOW.

configure:9858: checking location of curses.h file
configure:9901: result: /usr/mylocal/include/ncurses/ncurses.h
configure:10142: checking if curses is usable
configure:10171: gcc -o conftest -g -O2 -I/usr/mylocal/include -L/usr/mylocal/lib -lncurses conftest.c >&5
/tmp/ccAGkDPW.o: In function `main’:
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:37: undefined reference to `initscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:38: undefined reference to `printw’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:39: undefined reference to `stdscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:39: undefined reference to `wrefresh’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `stdscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `wgetch’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `stdscr’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:40: undefined reference to `wgetch’
/home/myuser/apps/wip/pinfo-0.6.9/conftest.c:41: undefined reference to `endwin’
collect2: ld returned 1 exit status
configure:10177: $? = 1
configure: failed program was:
|
| /* confdefs.h. */
|
| #define PACKAGE_NAME “pinfo”
| #define PACKAGE_TARNAME “pinfo”
| #define PACKAGE_VERSION “0.6.9″
| #define PACKAGE_STRING “pinfo 0.6.9″
| #define PACKAGE_BUGREPORT “pinfo-devel@lists.alioth.debian.org”
| #define PACKAGE “pinfo”
| #define VERSION “0.6.9″
| #define HAVE_STRDUP 1
| #define HAVE_STRSTR 1
| #define HAVE_STRSEP 1
| #define HAVE_GETOPT_LONG 1
| #define HAVE_SNPRINTF 1
| #define HAVE_SIGBLOCK 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define HAS_READLINE 1
| /* end confdefs.h. */
|
| #include
|
| int
| main ()
| {
|
| initscr();
| printw(“Hello World !!!”);
| refresh();
| getch();
| endwin();
| return 0;
|
|
| ;
| return 0;
| }
configure:10202: result: no
configure:10546: error: Curses not found. You need curses to compile pinfo

However, all the routines are there when I check /usr/mylocal/include/ncurses/ncurses.h

$ grep -w initscr /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */
$ grep -w printw /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(int) printw (const char *,…) /* implemented */
$ grep -w refresh /usr/mylocal/include/ncurses/ncurses.h
#define _HASMOVED 0×20 /* has cursor moved since last refresh? */
extern NCURSES_EXPORT(int) refresh (void); /* generated */
#define refresh() wrefresh(stdscr)
#define KEY_REFRESH 0565 /* refresh key */
#undef refresh
$ grep -w getch /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(int) getch (void); /* generated */
#define getch() wgetch(stdscr)
$ grep endwin /usr/mylocal/include/ncurses/ncurses.h
extern NCURSES_EXPORT(int) endwin (void); /* implemented */
extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */
$

I managed to get it to build using
gcc -o conftest.o conftest.c -I/usr/mylocal/include -g -L/usr/mylocal/lib -lncurses
instead of
gcc -o conftest -g -O2 -I/usr/mylocal/include -L/usr/mylocal/lib -lncurses conftest.c
so lets try
gcc -o conftest conftest.c -g -O2 -I/usr/mylocal/include -L/usr/mylocal/lib -lncurses

Hmm. Looks like it has something to do with the position of the source file in the command which is very strange as the manual says

You can mix options and other arguments. For the most part, the order you use doesn’t matter. Order does matter when you use several options of the same kind; for example, if you specify -L more than once, the directories are searched in the order specified.

So for the time being, I have modified configure so that the definition for ac_link (in 9 places) is now
ac_link=’$CC -o conftest$ac_exeext conftest.$ac_ext $CFLAGS $CPPFLAGS $LDFLAGS $LIBS >&5′

An excellent guide to gcc and other utilities by BRUCE PERENS can be found at faqs.org


Details of hunt for initscr from ncurses.h

  1. //usr/mylocal/include/ncurses/ncurses.h
  2. extern NCURSES_EXPORT(WINDOW *) initscr (void);                         /* implemented */
  3. NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
  4. #define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
  5. typedef struct _win_st WINDOW;
  6.  
  7. struct _win_st
  8. {
  9.         NCURSES_SIZE_T _cury, _curx; /* current cursor position */
  10.  
  11.         /* window location and size */
  12.         NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */
  13.         NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */
  14.  
  15.         short   _flags;         /* window state flags */
  16.  
  17.  
  18.         /* attribute tracking */
  19.         attr_t  _attrs;         /* current attribute for non-space character */
  20.         chtype  _bkgd;          /* current background char/attribute pair */
  21.  
  22.         /* option values set by user */
  23.         bool    _notimeout;     /* no time out on function-key entry? */
  24.         bool    _clear;         /* consider all data in the window invalid? */
  25.         bool    _leaveok;       /* OK to not reset cursor on exit? */
  26.         bool    _scroll;        /* OK to scroll this window? */
  27.         bool    _idlok;         /* OK to use insert/delete line? */
  28.         bool    _idcok;         /* OK to use insert/delete char? */
  29.         bool    _immed;         /* window in immed mode? (not yet used) */
  30.         bool    _sync;          /* window in sync mode? */
  31.         bool    _use_keypad;    /* process function keys into KEY_ symbols? */
  32.         int     _delay;         /* 0 = nodelay, <0 = blocking, >0 = delay */
  33.  
  34.         struct ldat *_line;     /* the actual line data */
  35.  
  36.         /* global screen state */
  37.         NCURSES_SIZE_T _regtop; /* top line of scrolling region */
  38.         NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */
  39.  
  40.         /* these are used only if this is a sub-window */
  41.         int     _parx;          /* x coordinate of this window in parent */
  42.         int     _pary;          /* y coordinate of this window in parent */
  43.         WINDOW  *_parent;       /* pointer to parent if a sub-window */
  44.  
  45.         /* these are used only if this is a pad */
  46.         struct pdat
  47.         {
  48.             NCURSES_SIZE_T _pad_y,      _pa
  49.             NCURSES_SIZE_T _pad_top,    _pad_left;
  50.             NCURSES_SIZE_T _pad_bottom, _pad_right;
  51.         } _pad;
  52.  
  53.         NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
  54.  
  55. #ifdef _XOPEN_SOURCE_EXTENDED
  56.         cchar_t  _bkgrnd;       /* current background char/attribute pair */
  57. #if 0
  58.         int     _color;         /* current color-pair for non-space character */
  59. #endif
  60. #endif
  61. }

phpMyAdmin

Despite all the claims, phpMyAdmin will not work with register_globals=Off in php.ini

What to do?

Make sure HAVE_PHP is defined so that Apache loads the php modules as this is a requirement. The Apache manual says that

The <IfDefine test>…</IfDefine> section is used to mark directives that are conditional. The directives within an IfDefine section are only processed if the test is true. If test is false, everything between the start and end markers is ignored.

The test in the <IfDefine> section directive can be one of two forms:

* parameter-name
* !parameter-name

In the former case, the directives between the start and end markers are only processed if the parameter named parameter-name is defined. The second format reverses the test, and only processes the directives if parameter-name is not defined.

The parameter-name argument is a define as given on the httpd command line via -Dparameter-, at the time the server was started.

So we need to investigate how Apache is started. This is done by the httpd startup file in /etc/rc.d/rc2.d. This scans the installed modules listed in moduledir (/usr/lib/apache) and converts their names into arguments that httpd can use by removing MOD_ or LIB from the start and .SO from the end of any filenames and appending this to -DHAVE_. The code is shown below

  1. /usr/bin/find /usr/lib/apache -type f -perm -0100 -name "*" | env -i tr '[:lower:]' '[:upper:]' | awk '{\
  2.          gsub(/.*\//,"");\
  3.          gsub(/^MOD_/,"");\
  4.          gsub(/^LIB/,"");\
  5.          gsub(/\.SO$/,"");\
  6.          print "-DHAVE_" $0}'

Our moduledir contains the file libphp4.so and so we therefore have HAVE_PHP4 defined which will cause Apache to load the required module.

<IfDefine HAVE_PHP>
LoadModule php_module modules/mod_php.so
</IfDefine>
<IfDefine HAVE_PHP3>
LoadModule php3_module modules/libphp3.so
</IfDefine>
<IfDefine HAVE_PHP4>
LoadModule php4_module modules/libphp4.so
</IfDefine>

<IfDefine HAVE_PHP>
AddModule mod_php.c
</IfDefine>
<IfDefine HAVE_PHP3>
AddModule mod_php3.c
</IfDefine>
<IfDefine HAVE_PHP4>
AddModule mod_php4.c
</IfDefine>

So the problem must lie in our phpMyadmin configuration file config.inc.php. Problem solved! Definition for $cfg['PmaAbsoluteUri'] needs to be in double quotes:

$cfg['PmaAbsoluteUri'] = “http://” . $_SERVER['HTTP_HOST'] . “/path/to/phpMyAdmin/”;

Procmail recipes

If you want to modify your procmail.rc rules file, then I suggest that you try your rule in isolation first before you break procmail and cause problems.
The first thing to do is to create the file with your test rule in it.

  • pico proctest.rc
    1. SHELL=/bin/sh
    2. TESTDIR=/home/rollingr/test
    3. MAILDIR=${TESTDIR}
    4. LOGFILE=${TESTDIR}/results.log
    5. LOG="--- Logging for ${LOGNAME}, "
    6.  
    7. #Troubleshooting:
    8. VERBOSE=yes
    9. LOGABSTRACT=all
    10.  
    11.  
    12. ##Insert your rule here instead of sample ##
    13. # Start of sample recipe to bounce blacklisted mail
    14. :0
    15. # Test whether required user is in any of these fields
    16. #Original-, Resent-, To, Cc, Bcc,.X-Envelope-To, Apparently-To or -Resent-To
    17. * ^TO_requireduser@mydomain.com
    18. # If match found then
    19. {
    20.   # Check if the sender is whitelisted
    21.   # Lock destination file for writing if match
    22.   :0:
    23.   # Extract headers From, Sender, Reply-To, Return-Path, To
    24.   # and compare to entries in white.list
    25.   # Entries should take form [email]me@my\.domain[/email]
    26.   # otherwise dot will match any character
    27.   # grep case insensitive, supress errors
    28.   # Click for a full explanation of [url=http://unixhelp.ed.ac.uk/CGI/man-cgi?egrep]egrep[/url]
    29.   * ? formail -x"From" -x"From:" -x"Sender:" \
    30.       -x"Reply-To:" -x"Return-Path:" -x"To:" \
    31.       | egrep -is -f white.lst
    32.   # If match found, deliver to /path/to/mailbox and stop
    33.   /path/to/mailbox
    34.  
    35.   # Bounce unwanted mail
    36.   # Start test - strip body from message
    37.      :0 h
    38.     # If not from mailing daemon
    39.     * ! ^FROM_DAEMON
    40.     # and not bounce of a bounce
    41.     * ! ^X-Loop: bounced@mydomain.com
    42.     # then pipe header with extra bounced header and error message in body to sendmail and stop
    43.     | ( formail -rt -A "X-Loop: bounced@mydomain.com"; \
    44.         echo "Your email address is not on our whitelist.  Please go to [url]http://www.mydomain.com/whitelist[/url] and subscribe"; \
    45.         ) | $SENDMAIL -t
    46.  
    47.   # If we got this far, then message is on blacklist and was previously bounced or is from the mailing daemon, so throw it away and stop
    48.   # Bin everything else sent to this user (such as bounces)
    49.   :0
    50.   /dev/null
    51. }
    52. # if not to required user then continue processing
    53.  
    54. ## End of sample Recipe ##
    55.  
    56.  
    57. # Catch anything that failed test Recipe here
    58. :0
    59. ${TESTDIR}failed.mail

    Now we need to create the supporting files

  • pico white.lst
    anyuser\@gmail\.com
  • Generate a valid message file which will trigger the rule
    1. From anyuser@gmail.com  Wed Nov 15 08:48:26 2006
    2. Return-Path: <anyuser@gmail.com>
    3. Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.170])
    4.         by mydomain.com (8.11.6/8.11.6) with ESMTP id kAFFmPd29195
    5.         for <me@mydomain.com>; Wed, 15 Nov 2006 08:48:25 -0700
    6. Received: by 10.66.252.9 with HTTP; Wed, 15 Nov 2006 07:48:23 -0800 (PST)
    7. Message-ID: <6757a1050611150748h6b0ada1fkf4dfe9aaefe721db@mail.gmail.com>
    8. Date: Wed, 15 Nov 2006 15:48:23 +0000
    9. From: "Sender" <anyuser@gmail.com>
    10. To: "Recipient" <me@mydomain.com>
    11. Subject: Testing Mail Header
    12. MIME-Version: 1.0
    13. Content-Type: text/plain; charset=ISO-8859-1; format=flowed
    14. Content-Transfer-Encoding: 7bit
    15. Content-Disposition: inline
    16.  
    17. This is a test for procmail
    18.  
    19. --
    20. Richard

    Next create a batch file to run the rule. Point TESTDIR to your directory.

  • pico procmail.bat
    1. #!/bin/sh
    2. #The executable file named "proctest"
    3. #
    4. # You need a test directory.
    5. TESTDIR=/home/yourlogin/test
    6. if [ ! -d ${TESTDIR} ] ; then
    7.   echo "Directory ${TESTDIR} does not exist; First create it"
    8.   exit 0
    9. fi
    10. #
    11. #Feed an email message to procmail. Apply proctest.rc recipes file.
    12. #First prepare a mail.msg email file which you wish to use for the
    13. #testing.
    14. procmail ${TESTDIR}/recipe.rc < mail.msg
    15. #
    16. #Show the results.
    17. less ${TESTDIR}/results.log
    18. #
    19. #Clean up.
    20. rm -i ${TESTDIR}/results.log
    21. rm -i ${TESTDIR}/failed.mail
  • And make it an executable
    chmod u+x procmail.bat
  • Run the test
    procmail.bat

phpMyAdmin – Invalid hostname for server 2

If you have installed phpMyAdmin, you may get the errors

Invalid hostname for server 2. Please review your configuration.
Invalid hostname for server 3. Please review your configuration.

when you log in. If so, the solution is to comment out this block of code in config.inc.php (it appears twice) – just wrap it in ‘/*’ and ‘*/’ as I have below

  1. /* This has been commented out because of error message
  2. $i++;
  3. $cfg['Servers'][$i]['host']            = '';
  4. $cfg['Servers'][$i]['port']            = '';
  5. $cfg['Servers'][$i]['socket']          = '';
  6. $cfg['Servers'][$i]['connect_type']    = 'tcp';
  7. $cfg['Servers'][$i]['extension']       = 'mysql';
  8. $cfg['Servers'][$i]['compress']        = FALSE;
  9. $cfg['Servers'][$i]['controluser']     = '';
  10. $cfg['Servers'][$i]['controlpass']     = '';
  11. $cfg['Servers'][$i]['auth_type']       = 'config';
  12. $cfg['Servers'][$i]['user']            = 'root';
  13. $cfg['Servers'][$i]['password']        = '';
  14. $cfg['Servers'][$i]['only_db']         = '';
  15. $cfg['Servers'][$i]['verbose']         = '';
  16. $cfg['Servers'][$i]['pmadb']           = ''; // 'phpmyadmin' - see scripts/create_tables.sql
  17. $cfg['Servers'][$i]['bookmarktable']   = ''; // 'pma_bookmark'
  18. $cfg['Servers'][$i]['relation']        = ''; // 'pma_relation'
  19. $cfg['Servers'][$i]['table_info']      = ''; // 'pma_table_info'
  20. $cfg['Servers'][$i]['table_coords']    = ''; // 'pma_table_coords'
  21. $cfg['Servers'][$i]['pdf_pages']       = ''; // 'pma_pdf_pages'
  22. $cfg['Servers'][$i]['column_info']     = ''; // 'pma_column_info'
  23. $cfg['Servers'][$i]['history']         = ''; // 'pma_history'
  24. $cfg['Servers'][$i]['verbose_check']   = TRUE;
  25. $cfg['Servers'][$i]['AllowDeny']['order']
  26.                                        = '';
  27. $cfg['Servers'][$i]['AllowDeny']['rules']
  28.                                        = array();
  29. */