Re: Patches for saned/net/scanimage/user-authorization....

From: Henning Meier-Geinitz (hmg-ml@gmx.de)
Date: Sat Nov 18 2000 - 11:33:09 PST

  • Next message: Oliver Neukum: "Re: Linux Support for Current Microtek Scanners"

    Hi,

    First: Compilation, installation and testing with saned and scanimage
    results:

    ****************************************************************************
    Linux 2.2 i386
    everything works
    ****************************************************************************

    ****************************************************************************
    Sun Solaris with gcc:
    gcc -c -DHAVE_CONFIG_H -I. -I. -I../include -I../include -D_GNU_SOURCE
    -DPATH_SANE_CONFIG_DIR=/tmp/sane-bin/etc/sane.d
    -DPATH_SANE_DATA_DIR=/tmp/sane-bin/share -DV_MAJOR=1 -DV_MINOR=0 -g
    -O2 -W -Wall -Wstrict-prototypes -Wreturn-type -Wcast-align
    -Wpointer-arith -Wcast-qual -ansi -pedantic -DSCSIBUFFERSIZE=131072
    sanei_auth.c -fPIC -DPIC -o .libs/sanei_auth.lo
    In file included from sanei_auth.c:43:
    ../include/sane/config.h:371: warning: function declaration isn't a
    prototype
    ../include/sane/config.h:376: warning: function declaration isn't a
    prototype
    sanei_auth.c: In function sanei_authorize':
    sanei_auth.c:194: warning: implicit declaration of function index'
    sanei_auth.c:194: invalid operands to binary -
    sanei_auth.c:223: warning: unsigned int format, long unsigned int arg
    (arg 4)
    sanei_auth.c:223: warning: long unsigned int format, unsigned int arg
    (arg 6)
    sanei_auth.c:238: invalid operands to binary -
    sanei_auth.c:241: warning: assignment makes pointer from integer
    without a cast
    sanei_auth.c:244: invalid operands to binary -
    sanei_auth.c:247: warning: assignment makes pointer from integer
    without a cast
    gmake[1]: *** [sanei_auth.o] Error 1

    The problem is that strings.h is not included. From man index:
    SYNOPSIS
         #include <strings.h>
         
         char *index(const char *s, int c);
              
         char *rindex(const char *s, int c);

    Adding #include <strings.h> works. So add a test to
    configure.in/config.h for strings.h?

    Then in scanimage.c:
    gcc -c -DHAVE_CONFIG_H -I. -I. -I../include -I../include
    -I/usr/local/include -D_GNU_SOURCE
    -DPATH_SANE_CONFIG_DIR=/tmp/sane-bin/etc/sane.d
    -DPATH_SANE_DATA_DIR=/tmp/sane-bin/share -DV_MAJOR=1
    -DV_MINOR=0 -g -O2 -W -Wall -Wstrict-prototypes -Wreturn-type
    -Wcast-align -Wpointer-arith -Wcast-qual -ansi -pedantic
    -DSCSIBUFFERSIZE=131072 scanimage.c
    In file included from scanimage.c:25:
    ../include/sane/config.h:371: warning: function declaration isn't a
    prototype
    ../include/sane/config.h:376: warning: function declaration isn't a
    prototype
    In file included from scanimage.c:29:
    ../include/getopt.h:104: warning: function declaration isn't a prototype
    scanimage.c: In function auth_callback':
    scanimage.c:148: warning: implicit declaration of function index'
    scanimage.c:148: invalid operands to binary -
    scanimage.c:154: warning: passing arg 2 of strncpy' makes pointer from
    integer without a cast
    scanimage.c:160: warning: passing arg 2 of strncpy' makes pointer from
    integer without a cast
    scanimage.c: In function fetch_options':
    scanimage.c:682: warning: cast discards qualifiers from pointer target
    type
    scanimage.c: In function process_backend_option':
    scanimage.c:872: warning: cast discards qualifiers from pointer target
    type
    gmake[1]: *** [scanimage.o] Error 1

    Same problem, same solution.
    Also saned:
    gcc -c -DHAVE_CONFIG_H -I. -I. -I../include -I../include
    -I/usr/local/include -D_GNU_SOURCE
    -DPATH_SANE_CONFIG_DIR=/tmp/sane-bin/etc/sane.d
    -DPATH_SANE_DATA_DIR=/tmp/sane-bin/share -DV_MAJOR=1
    -DV_MINOR=0 -g -O2 -W -Wall -Wstrict-prototypes -Wreturn-type
    -Wcast-align -Wpointer-arith -Wcast-qual -ansi -pedantic
    -DSCSIBUFFERSIZE=131072 saned.c
    In file included from saned.c:27:
    ../include/sane/config.h:371: warning: function declaration isn't a
    prototype
    ../include/sane/config.h:376: warning: function declaration isn't a
    prototype
    saned.c: In function auth_callback':
    saned.c:173: warning: cast discards qualifiers from pointer target type
    saned.c:183: warning: cast discards qualifiers from pointer target type
    saned.c:194: warning: cast discards qualifiers from pointer target type
    saned.c: In function decode_handle':
    saned.c:312: warning: comparison between signed and unsigned
    saned.c: In function store_reclen':
    saned.c:539: warning: comparison between signed and unsigned
    saned.c:542: warning: comparison between signed and unsigned
    saned.c:545: warning: comparison between signed and unsigned
    saned.c:548: warning: comparison between signed and unsigned
    saned.c: In function do_scan':
    saned.c:651: warning: comparison between signed and unsigned
    saned.c:665: warning: comparison between signed and unsigned
    saned.c: In function process_request':
    saned.c:744: warning: implicit declaration of function index'
    saned.c:745: invalid type argument of unary *'
    saned.c:807: warning: cast discards qualifiers from pointer target type
    saned.c:823: warning: comparison between signed and unsigned
    saned.c: In function main':
    saned.c:984: warning: passing arg 4 of setsockopt' from incompatible pointer type
    gmake[1]: *** [saned.o] Error 1

    Same problem, same solution :-)
    After adding these three #include <strings.h> lines, everything works.

    ****************************************************************************

    ****************************************************************************
    Irix 6.2 with SGI cc:
    cc -c -DHAVE_CONFIG_H -I. -I. -I../include -I../include -D_GNU_SOURCE
    -DPATH_SANE_CONFIG_DIR=/tmp/sane-bin/etc/sane.d
    -DPATH_SANE_DATA_DIR=/tmp/sane-bin/share -DV_MAJOR=1 -DV_MINOR=0 -g
    -DSCSIBUFFERSIZE=131072 sanei_auth.c -DPIC -o .libs/sanei_auth.lo
    cfe: Error: sanei_auth.c, line 194: Unacceptable operand of '-'.
      if (((index (line, ':')) - line) == (signed) strlen (resource))
    ---------------------------^
    cfe: Error: sanei_auth.c, line 238: Unacceptable operand of '-'.
      (((index (line, ':')) - line) == (signed) strlen (resource)))
    ------------------------^
    cfe: Warning 712: sanei_auth.c, line 241: illegal combination of pointer and integer
      linep = index (line, ':') + 1;
    --------^
    cfe: Error: sanei_auth.c, line 244: Unacceptable operand of '-'.
      (((index (linep, ':')) - linep) == (signed) strlen (username)))
    -----------------------------^
    cfe: Warning 712: sanei_auth.c, line 247: illegal combination of pointer and integer
      linep = index (linep, ':') + 1;
    ------------^
    gmake[1]: *** [sanei_auth.o] Error 1

    For Irix, the man page says index is in string.h. But that's untrue.
    The compiler doesn't find a prototype and uses a return type of int.
    Thtat's the source of the error (you can't do (int) - (char *). Took
    me some time to find out :-)
    Changing string.h to strings.h in sanei_auth.c, saned.c and scanimage.c
    works.

    ****************************************************************************
    AIX with gcc:
    Works.
    ****************************************************************************

    index() is also used in mustek_pp (maybe others) so we should look a bit
    more at this. You don't seem to use pointer arithmetics (or in a
    different way) in mustek_pp so probably this is why the compilers
    don't bail out there.

    On Fri, Nov 17, 2000 at 11:35:23AM +0100, Jochen Eisinger wrote:
    > SANE Standard (then 1.0.2)

    I think this small change is acceptable. Have anyone used authorization
    at all until now?

    The concept looks ok but I didn't look into the details (and I'm not an
    expert in encryption things).

    > lib/md5.c include/md5.h include/sane/sanei_auth.h sanei/sanei_auth.c:

    mhh, ugly k&r style C :-). Seems to work however.

    > frontend/scanimage.c frontend/saned.c doc/saned.man doc/scanimage.man:
    >
    > furthermore, I've modified scanimage to handle such requests... if a
    > file ~/.sane/pass exists, it is used to automate the process
    > (permissions must be 0600 at least, the format is the same as for
    > sanei_authorize). To make sure the frontend isn't replying to old
    > unsecures password-request, you can use the command-line option
    > --accept-md5-only.

    The output
    [resource] user:
    may be a bit confusing because the debug output uses a similar form.
    Can we use a more detailed output like:
    "Authentification required for resource %s. Enter username: "
    "Enter password:"

    > please send feedback!!

    In my opinion you can add the changes to CVS when the index problems
    are resolved.

    Bye,
      Henning

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Sat Nov 18 2000 - 11:17:34 PST