"Fossies" - the Fresh Open Source Software Archive

Member "pidentd-3.0.19/src/k_dummy.c" (20 Jan 1999, 2000 Bytes) of package /linux/misc/old/pidentd-3.0.19.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "k_dummy.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2 ** k_dummy.c - A dummy (demonstration) kernel access module
    3 **
    4 ** Copyright (c) 1997 Peter Eriksson <pen@lysator.liu.se>
    5 **
    6 ** This program is free software; you can redistribute it and/or
    7 ** modify it as you wish - as long as you don't claim that you wrote
    8 ** it.
    9 **
   10 ** This program is distributed in the hope that it will be useful,
   11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   13 */
   14 
   15 #include "config.h"
   16 
   17 #include <stdio.h>
   18 
   19 #include "pidentd.h"
   20 
   21 /*
   22 ** ka_init should verify that the binary is running on a
   23 ** supported OS version (in most cases it should verify
   24 ** that it is running on exactly the same version as it was
   25 ** compiled on).
   26 */
   27 int
   28 ka_init(void)
   29 {
   30     char osinfo_current[256];
   31 
   32     if (osinfo_get(osinfo_current) == NULL)
   33     return -1;
   34 
   35     return strcmp(osinfo_build, osinfo_current);
   36 }
   37 
   38 
   39 
   40 /*
   41 ** ka_open should open any kernel file descriptors or other
   42 ** resources needed to access it, put it into some dynamically
   43 ** allocated structure and store it into the 'misc' pointer.
   44 **
   45 ** It should return 0 if all was OK, else -1
   46 */
   47 int
   48 ka_open(void **misc)
   49 {
   50     *misc = NULL;
   51     return 0;
   52 }
   53 
   54 
   55 
   56 /*
   57 ** ka_lookup gets called when a request thread wants to
   58 ** do a kernel lookup.
   59 **
   60 ** The pointer returned from ka_init() is passed as the "vp" parameter.
   61 ** The local and remote address and port is available in the "kp"
   62 ** parameter.
   63 **
   64 ** The function should set both the effective uid and real uid (if
   65 ** either one isn't available, return -1 in that return variable)
   66 ** variables in the "struct kernel" argument.
   67 **
   68 ** This function should return a 1 if the lookup was successful,
   69 ** a zero if the connection wasn't found or a -1 in case an error
   70 ** occured (the call to ka_lookup() will be retried if -1 
   71 ** is returned a configurable number of times, but will fail
   72 ** immediately in case of a 0).
   73 */
   74 int
   75 ka_lookup(void *vp, struct kernel *kp)
   76 {
   77     kp->euid = 12;
   78     kp->ruid = 121;
   79     
   80     return 1;
   81 }