home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / vcron.t.Z / vcron.t / VCRON / database.c < prev    next >
Text File  |  1988-11-15  |  2KB  |  93 lines

  1. /* $Source: /h0/usr/local/src/crond/database.c,v $
  2.  * $Revision: 1.3 $
  3.  * $Log:    databasenew.c,v $
  4.  * Revision 1.3  88/04/20  20:30:00  ram
  5.  * OSK-Verion. use Group-entry for crontab-owner
  6.  *
  7.  * Revision 1.2  87/05/02  17:33:31  paul
  8.  * baseline for mod.sources release
  9.  * 
  10.  * Revision 1.1  87/01/26  23:46:36  paul
  11.  * Initial revision
  12.  * 
  13.  */
  14.  
  15. /* Copyright 1987 by Vixie Enterprises
  16.  * All rights reserved
  17.  *
  18.  * Distribute freely, except: don't sell it, don't remove my name from the
  19.  * source or documentation (don't take credit for my work), mark your changes
  20.  * (don't get me blamed for your possible bugs), don't alter or remove this
  21.  * notice.  Commercial redistribution is negotiable; contact me for details.
  22.  *
  23.  * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  24.  * I'll try to keep a version up to date.  I can be reached as follows:
  25.  * Paul Vixie, Vixie Enterprises, 329 Noe Street, San Francisco, CA, 94114,
  26.  * (415) 864-7013, {ucbvax!dual,ames,ucsfmis,lll-crg,sun}!ptsfa!vixie!paul.
  27.  */
  28.  
  29.  
  30. #include "cron.h"
  31. #include <pwd.h>
  32. #include <grp.h>
  33. # include <types.h>
  34.  
  35. void
  36. free_database(db)
  37.     user    *db;
  38. {
  39.     void    free_user();
  40.     user    *u;
  41.  
  42.     for (u = db;  u != NULL;  u = u->next)
  43.         free_user(u);
  44. }
  45.  
  46.  
  47. user *
  48. load_database()
  49. {
  50.     user        *load_user();
  51.  
  52.     struct passwd    *pw;
  53.     REG  user    *db, *u;
  54.     struct group    *crongrp;
  55.     REG  char    **i;
  56.  
  57. #if DEBUGGING
  58.     Debug(DPARS, "load_database()\n");
  59. #endif
  60.  
  61.     db = NULL;
  62.     if(!(crongrp =getgrnam(CRON_GRP))) {
  63.       perror("No Group entry for Cron-group\n");
  64.       exit(1);
  65.     }
  66.  
  67.     for( i = crongrp->gr_mem; *i ; i++) {
  68.         if(pw = getpwnam(*i)) {
  69. #if DEBUGGING
  70.               Debug(DPARS, "\t%s\n", i);
  71. #endif
  72.             u = load_user(
  73.             pw->pw_name,
  74.             pw->pw_uid,
  75.             pw->pw_gid,
  76.             pw->pw_dir,
  77.             pw->pw_xdir,
  78.             pw->pw_shell );
  79.             if (u == NULL)
  80.             {
  81.                 /* no crontab for this user
  82.                  */
  83.                 continue;
  84.             }
  85.             u->next = db;
  86.             db = u;
  87.         }
  88.     }
  89.     endpwent();
  90.     endgrent();
  91.     return db ;
  92. }
  93.