IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25035


Ignore:
Timestamp:
Aug 10, 2009, 3:47:42 AM (17 years ago)
Author:
eugene
Message:

adjust dvo locking to allow read-only access to databases in dvo shell

Location:
branches/eam_branches/20090715/Ohana/src
Files:
1 added
46 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit.c

    r25020 r25035  
    180180  /* XXX this does not yet write out the master photcode table */
    181181  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    182   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     182  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    183183    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    184184    exit (1);
  • branches/eam_branches/20090715/Ohana/src/addstar/src/ConfigInit_skycells.c

    r16061 r25035  
    5555  /* XXX this does not yet write out the master photcode table */
    5656  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    57   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     57  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    5858    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    5959    exit (1);
  • branches/eam_branches/20090715/Ohana/src/addstar/src/addstar.c

    r21508 r25035  
    2525  options = args (argc, argv, options);
    2626
    27   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     27  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    2828  if (sky == NULL) {
    2929      fprintf (stderr, "ERROR: unable to load sky table data\n");
  • branches/eam_branches/20090715/Ohana/src/addstar/src/addstard.c

    r6236 r25035  
    1212
    1313  /* store the sky table in a global for internal use */
    14   ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     14  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1515  SkyTableSetFilenames (ServerSky, CATDIR, "cpt");
    1616
  • branches/eam_branches/20090715/Ohana/src/addstar/src/addstart.c

    r10939 r25035  
    1212
    1313  /* store the sky table in a global for internal use */
    14   ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     14  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1515  SkyTableSetFilenames (ServerSky, CATDIR, "cpt");
    1616
  • branches/eam_branches/20090715/Ohana/src/addstar/src/load2mass.c

    r25020 r25035  
    1616
    1717  // load the full sky description table:
    18   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     18  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1919  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2020 
  • branches/eam_branches/20090715/Ohana/src/addstar/src/sedstar.c

    r15743 r25035  
    1515  options = args_sedstar (argc, argv, options);
    1616
    17   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     17  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1818  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1919 
  • branches/eam_branches/20090715/Ohana/src/delstar/src/ConfigInit.c

    r12332 r25035  
    4545  /* XXX this does not yet write out the master photcode table */
    4646  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    47   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     47  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    4848    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    4949    exit (1);
  • branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagefile.c

    r15743 r25035  
    1212
    1313  /* load sky from correct table */
    14   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     14  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1515  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1616
  • branches/eam_branches/20090715/Ohana/src/delstar/src/delete_imagename.c

    r17245 r25035  
    1515
    1616  /* load sky from correct table */
    17   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     17  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1818  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1919
  • branches/eam_branches/20090715/Ohana/src/delstar/src/delete_times.c

    r15743 r25035  
    1515
    1616  /* load sky from correct table */
    17   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     17  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1818  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1919
  • branches/eam_branches/20090715/Ohana/src/dvomerge/src/dvomerge.c

    r24750 r25035  
    2424  // the first input define the photcode table & db layout
    2525  sprintf (filename, "%s/Photcodes.dat", input1);
    26   if (!LoadPhotcodes (filename, NULL)) {
     26  if (!LoadPhotcodes (filename, NULL, FALSE)) {
    2727    fprintf (stderr, "error loading photcode table %s\n", filename);
    2828    exit (1);
     
    3030  // save the photcodes in the output catdir
    3131  sprintf (filename, "%s/Photcodes.dat", output);
    32   if (!check_file_access (filename, TRUE, TRUE)) {
     32  if (!check_file_access (filename, TRUE, TRUE, TRUE)) {
    3333    fprintf (stderr, "error creating output catdir %s\n", output);
    3434    exit (1);
     
    4040
    4141  // load the sky table for the existing database
    42   insky1 = SkyTableLoadOptimal (input1, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
     42  insky1 = SkyTableLoadOptimal (input1, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
    4343  SkyTableSetFilenames (insky1, input1, "cpt");
    4444
    45   insky2 = SkyTableLoadOptimal (input2, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
     45  insky2 = SkyTableLoadOptimal (input2, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
    4646  SkyTableSetFilenames (insky2, input2, "cpt");
    4747
    4848  // generate an output table populated at the desired depth
    49   outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, SKY_DEPTH, VERBOSE);
     49  outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    5050  SkyTableSetFilenames (outsky, output, "cpt");
    5151
     
    117117  // save the output sky table copy
    118118  sprintf (filename, "%s/SkyTable.fits", output);
    119   check_file_access (filename, TRUE, VERBOSE);
     119  check_file_access (filename, TRUE, TRUE, VERBOSE);
    120120  if (!SkyTableSave (outsky, filename)) {
    121121    fprintf (stderr, "ERROR: failed to save sky table for %s\n", output);
  • branches/eam_branches/20090715/Ohana/src/dvosplit/src/ConfigInit.c

    r24753 r25035  
    3333  /* XXX this does not yet write out the master photcode table */
    3434  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    35   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     35  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3636    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3737    exit (1);
  • branches/eam_branches/20090715/Ohana/src/dvosplit/src/dvosplit.c

    r15746 r25035  
    1818
    1919  // load the sky table for the existing database
    20   sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
     20  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, SKY_DEPTH_HST, VERBOSE);
    2121  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2222
     
    7979  // save sky table copy
    8080  sprintf (filename, "%s/SkyTable.fits", CATDIR);
    81   check_file_access (filename, TRUE, VERBOSE);
     81  check_file_access (filename, TRUE, TRUE, VERBOSE);
    8282  if (!SkyTableSave (sky, filename)) {
    8383    fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);
  • branches/eam_branches/20090715/Ohana/src/gastro/src/getptolemy.c

    r16810 r25035  
    1919
    2020  /* load regions from GSC table, restrict to patch */
    21   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     21  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
    2222  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2323  skylist = SkyListByPatch (sky, -1, &patch);
  • branches/eam_branches/20090715/Ohana/src/gastro2/src/getptolemy.c

    r16810 r25035  
    2121
    2222  /* load regions from GSC table, restrict to patch */
    23   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     23  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
    2424  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2525  skylist = SkyListByPatch (sky, -1, &patch);
  • branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit.c

    r15543 r25035  
    3434  /* XXX this does not yet write out the master photcode table */
    3535  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    36   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     36  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3737    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3838    exit (1);
  • branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_coords.c

    r25020 r25035  
    3535  /* XXX this does not yet write out the master photcode table */
    3636  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    37   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     37  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3838    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3939    exit (1);
  • branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_extract.c

    r12840 r25035  
    3535  /* XXX this does not yet write out the master photcode table */
    3636  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    37   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     37  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3838    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3939    exit (1);
  • branches/eam_branches/20090715/Ohana/src/getstar/src/ConfigInit_overlaps.c

    r12774 r25035  
    3535  /* XXX this does not yet write out the master photcode table */
    3636  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    37   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     37  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) {
    3838    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3939    exit (1);
  • branches/eam_branches/20090715/Ohana/src/getstar/src/getstar.c

    r20984 r25035  
    1313  set_db (&db);
    1414
    15   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     15  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1616  if (!sky) exit (1);
    1717   
  • branches/eam_branches/20090715/Ohana/src/imregister/base/ConfigInit.c

    r12332 r25035  
    105105  /* XXX this does not yet write out the master photcode table */
    106106  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", catdir);
    107   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     107  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    108108    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    109109    exit (1);
  • branches/eam_branches/20090715/Ohana/src/imregister/imphot/ConfigInit.c

    r12332 r25035  
    101101  /* XXX this does not yet write out the master photcode table */
    102102  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    103   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     103  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    104104    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    105105    exit (1);
  • branches/eam_branches/20090715/Ohana/src/libdvo/include/dvo.h

    r25020 r25035  
    325325PhotCodeData *GetPhotcodeTable (void);
    326326
    327 int LoadPhotcodes (char *catdir_file, char *master_file);
     327int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite);
    328328int LoadPhotcodesText (char *filename);
    329329int LoadPhotcodesFITS (char *filename);
     
    432432SkyTable  *SkyTableLoad            PROTO((char *filename, int VERBOSE));
    433433SkyTable  *SkyTableFromGSC         PROTO((char *filename, int depth, int VERBOSE));
    434 SkyTable  *SkyTableLoadOptimal     PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int depth, int VERBOSE));
     434SkyTable  *SkyTableLoadOptimal     PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int readwrite, int depth, int VERBOSE));
    435435int        SkyTableSetDepth        PROTO((SkyTable *sky, int depth));
    436436SkyList   *SkyRegionByPoint        PROTO((SkyTable *table, int depth, double ra, double dec));
  • branches/eam_branches/20090715/Ohana/src/libdvo/src/LoadPhotcodes.c

    r12332 r25035  
    11# include <dvo.h>
    22
    3 int LoadPhotcodes (char *catdir_file, char *master_file) {
     3int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite) {
    44
    55  /* first try to load the photcodes from the specified CATDIR location */
    66  if (LoadPhotcodesFITS (catdir_file)) return TRUE;
    77 
     8  if (!readwrite) {
     9    fprintf (stderr, "db is missing a photcode table & access is read-only -- create one with photcode-table -import\n");
     10    return FALSE;
     11  }
     12
    813  /* next try to load the photcodes from the master text photcode file */
    914  /* automatically (or on demand?) save the text file to the FITS version */
    1015  if (LoadPhotcodesText (master_file)) {
    11       if (!check_file_access (catdir_file, TRUE, TRUE)) return TRUE;
    12       SavePhotcodesFITS (catdir_file);
    13       return TRUE;
     16    if (!check_file_access (catdir_file, TRUE, TRUE, TRUE)) return TRUE;
     17    SavePhotcodesFITS (catdir_file);
     18    return TRUE;
    1419  }
    1520
  • branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_catalog.c

    r24748 r25035  
    180180
    181181  int Nsecfilt, mode;
     182  int BACKUP, READWRITE;
    182183
    183184  mode = DVO_OPEN_NONE;
     
    192193  dvo_catalog_init (catalog, FALSE);
    193194
     195  // default access control options:
    194196  catalog[0].lockmode  = LCK_XCLD;
    195   if (mode == DVO_OPEN_READ) catalog[0].lockmode  = LCK_SOFT;
     197  BACKUP = TRUE;
     198  READWRITE = TRUE;
     199
     200  // in read-only mode, do not backup or require write access
     201  if (mode == DVO_OPEN_READ) {
     202    catalog[0].lockmode  = LCK_SOFT;
     203    BACKUP = FALSE;
     204    READWRITE = FALSE;
     205  }
    196206 
    197   // XXX make a backup?  always?
    198   if (!check_file_access (catalog[0].filename, TRUE, VERBOSE)) {
     207  if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) {
    199208    if (VERBOSE) fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
    200209    return (FALSE);
  • branches/eam_branches/20090715/Ohana/src/libdvo/src/dvo_image.c

    r24748 r25035  
    44int dvo_image_lock (FITS_DB *db, char *filename, double timeout, int lockstate) {
    55
    6   /* lock the image catalog */
    7   if (!check_file_access (filename, FALSE, TRUE)) return (FALSE);
     6  int READWRITE;
     7
     8  // default access control options:
     9  READWRITE = TRUE;
     10
     11  // in read-only mode, do not backup or require write access
     12  if (lockstate == LCK_SOFT) {
     13    READWRITE = FALSE;
     14  }
     15
     16  // do not perform a backup here
     17  if (!check_file_access (filename, FALSE, READWRITE, TRUE)) return (FALSE);
    818
    919  db[0].lockstate = lockstate;
  • branches/eam_branches/20090715/Ohana/src/libdvo/src/skyregion_io.c

    r17000 r25035  
    8484}
    8585
    86 SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int depth, int verbose) {
     86SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int readwrite, int depth, int verbose) {
    8787
    8888  char filename[256];
     
    9393  sprintf (filename, "%s/SkyTable.fits", catdir);
    9494  if (stat (filename, &filestat)) goto SKYFILE;
    95   if (!check_file_access (filename, FALSE, verbose)) goto SKYFILE;
     95  if (!check_file_access (filename, FALSE, readwrite, verbose)) goto SKYFILE;
    9696  sky = SkyTableLoad (filename, verbose);
    9797  if (sky == NULL) {
     
    106106  if (skyfile[0] != 0) goto GSCFILE;
    107107  if (stat (skyfile, &filestat)) goto GSCFILE;
    108   if (!check_file_access (skyfile, FALSE, verbose)) goto GSCFILE;
     108  if (!check_file_access (skyfile, FALSE, readwrite, verbose)) goto GSCFILE;
    109109  sky = SkyTableLoad (skyfile, verbose);
    110110  if (sky == NULL) {
     
    117117  /* create CATDIR copy */
    118118  sprintf (filename, "%s/SkyTable.fits", catdir);
    119   check_file_access (filename, FALSE, verbose);
     119  check_file_access (filename, FALSE, readwrite, verbose);
    120120  if (!SkyTableSave (sky, filename)) return NULL;
    121121
     
    134134  /* create CATDIR copy */
    135135  sprintf (filename, "%s/SkyTable.fits", catdir);
    136   check_file_access (filename, FALSE, verbose);
     136  check_file_access (filename, FALSE, readwrite, verbose);
    137137  if (!SkyTableSave (sky, filename)) return NULL;
    138138
  • branches/eam_branches/20090715/Ohana/src/libohana/include/ohana.h

    r21508 r25035  
    166166int     mkdirhier              PROTO((char *path, int mode));
    167167void    make_backup            PROTO((char *filename));
    168 int     check_file_access      PROTO((char *basefile, int backup, int verbose));
     168int     check_file_access      PROTO((char *basefile, int backup, int readwrite, int verbose));
    169169int     check_dir_access       PROTO((char *path, int verbose));
    170170int     check_file_exec        PROTO((char *filename));
  • branches/eam_branches/20090715/Ohana/src/libohana/src/findexec.c

    r18051 r25035  
    6767   - file backup permission OK (optional)
    6868*/
    69 int check_file_access (char *basefile, int BACKUP, int VERBOSE) {
     69int check_file_access (char *basefile, int BACKUP, int READWRITE, int VERBOSE) {
    7070 
    7171  char *path, *filename;
     
    7474  gid_t gid;
    7575  int status;
     76  int valid;
    7677
    7778  uid = getuid();
    7879  gid = getgid();
     80
     81  // XXX this function needs to call 'getgroups' to get the full list of the user's
     82  // groups.  we would then need to loop over all groups in the gid test below
     83  // to see if any match the file.  test to see how slow this is.
    7984
    8085  /* check permission to write to directory */
     
    8792  status = stat (basefile, &filestat);
    8893  if (status == 0) { /* file exists, are permissions OK? */
    89     if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
    90         ((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) ||
    91         ((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
    92     } else {
     94    valid = FALSE;
     95    if (!valid && (uid == filestat.st_uid)) {
     96      valid = (filestat.st_mode & S_IRUSR) != 0;
     97      valid &= !READWRITE || (filestat.st_mode & S_IWUSR);
     98    }
     99    if (!valid && (gid == filestat.st_gid)) {
     100      valid = (filestat.st_mode & S_IRGRP) != 0;
     101      valid &= !READWRITE || (filestat.st_mode & S_IWGRP);
     102    }
     103    if (!valid) {
     104      valid = (filestat.st_mode & S_IROTH) != 0;
     105      valid &= !READWRITE || (filestat.st_mode & S_IWOTH);
     106    }
     107    if (!valid) {
    93108      if (VERBOSE) fprintf (stderr, "can't write to %s\n", basefile);
    94109      return (FALSE);
     
    102117    status = stat (filename, &filestat);
    103118    if (status == 0) { /* file exists, are permissions OK? */
    104       if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
    105           ((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) ||
    106           ((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
    107       } else {
     119      valid = FALSE;
     120      if (!valid && (uid == filestat.st_uid)) {
     121        valid = (filestat.st_mode & S_IRUSR) != 0;
     122        valid &= !READWRITE || (filestat.st_mode & S_IWUSR);
     123      }
     124      if (!valid && (gid == filestat.st_gid)) {
     125        valid = (filestat.st_mode & S_IRGRP) != 0;
     126        valid &= !READWRITE || (filestat.st_mode & S_IWGRP);
     127      }
     128      if (!valid) {
     129        valid = (filestat.st_mode & S_IROTH) != 0;
     130        valid &= !READWRITE || (filestat.st_mode & S_IWOTH);
     131      }
     132      if (!valid) {
    108133        if (VERBOSE) fprintf (stderr, "can't write to %s\n", filename);
    109134        return (FALSE);
  • branches/eam_branches/20090715/Ohana/src/markrock/src/ConfigInit.c

    r12332 r25035  
    4444  /* XXX this does not yet write out the master photcode table */
    4545  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    46   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     46  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    4747    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    4848    exit (1);
  • branches/eam_branches/20090715/Ohana/src/markrock/src/markrock.c

    r15743 r25035  
    3333
    3434  /* if lockfile exists, program will complain and quit */
    35   if (!check_file_access (argv[1], TRUE, TRUE)) exit (1);
    36   if (!check_file_access (RockCat, TRUE, TRUE)) exit (1);
     35  if (!check_file_access (argv[1], TRUE, TRUE, TRUE)) exit (1);
     36  if (!check_file_access (RockCat, TRUE, TRUE, TRUE)) exit (1);
    3737
    3838  catalog.filename = argv[1];
  • branches/eam_branches/20090715/Ohana/src/markstar/src/ConfigInit.c

    r12332 r25035  
    5454  /* XXX this does not yet write out the master photcode table */
    5555  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    56   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     56  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    5757    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    5858    exit (1);
  • branches/eam_branches/20090715/Ohana/src/mosastro/src/getptolemy.c

    r16810 r25035  
    1919
    2020  /* load regions from GSC table, restrict to patch */
    21   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     21  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
    2222  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2323  skylist = SkyListByPatch (sky, -1, &patch);
  • branches/eam_branches/20090715/Ohana/src/opihi/cmd.data/Makefile

    r24992 r25035  
    9797$(SRC)/rebin.$(ARCH).o          \
    9898$(SRC)/resize.$(ARCH).o \
     99$(SRC)/relocate.$(ARCH).o       \
    99100$(SRC)/roll.$(ARCH).o           \
    100101$(SRC)/rotate.$(ARCH).o \
  • branches/eam_branches/20090715/Ohana/src/opihi/dvo/photometry.c

    r21508 r25035  
    325325    return (FALSE);
    326326  }
    327   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     327
     328  // XXX now that DVO does not allow write access, we can drop the MasterPhotcodeFile
     329  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) {
    328330    gprint (GP_ERR, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    329331    return (FALSE);
  • branches/eam_branches/20090715/Ohana/src/opihi/dvo/region_list.c

    r15753 r25035  
    4242
    4343  if (sky != NULL) SkyTableFree (sky);
    44   sky = SkyTableLoadOptimal (CATDIR, skyfile, gscfile, skydepth, verbose);
     44  sky = SkyTableLoadOptimal (CATDIR, skyfile, gscfile, FALSE, skydepth, verbose);
    4545  if (sky == NULL) return FALSE;
    4646
  • branches/eam_branches/20090715/Ohana/src/photdbc/src/ConfigInit.c

    r17284 r25035  
    6464  /* XXX this does not yet write out the master photcode table */
    6565  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    66   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     66  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    6767    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    6868    exit (1);
  • branches/eam_branches/20090715/Ohana/src/photdbc/src/photdbc.c

    r17284 r25035  
    1717
    1818  // the output catalog needs to inherit the SKY_DEPTH of the input catalog
    19   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     19  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, TRUE, SKY_DEPTH_HST, VERBOSE);
    2020  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2121  skylist = SkyListByPatch (sky, -1, &REGION);
  • branches/eam_branches/20090715/Ohana/src/relastro/src/ConfigInit.c

    r24308 r25035  
    6060  /* update master photcode table if not defined */
    6161  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    62   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     62  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    6363    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    6464    exit (1);
  • branches/eam_branches/20090715/Ohana/src/relastro/src/load_images.c

    r12332 r25035  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • branches/eam_branches/20090715/Ohana/src/relastro/src/relastro_objects.c

    r24308 r25035  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • branches/eam_branches/20090715/Ohana/src/relphot/src/ConfigInit.c

    r20323 r25035  
    5858  /* XXX this does not yet write out the master photcode table */
    5959  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    60   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     60  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    6161    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    6262    exit (1);
  • branches/eam_branches/20090715/Ohana/src/relphot/src/load_images.c

    r10506 r25035  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • branches/eam_branches/20090715/Ohana/src/relphot/src/relphot_objects.c

    r21508 r25035  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • branches/eam_branches/20090715/Ohana/src/uniphot/src/ConfigInit.c

    r12332 r25035  
    3636  /* XXX this does not yet write out the master photcode table */
    3737  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    38   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     38  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3939    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    4040    exit (1);
Note: See TracChangeset for help on using the changeset viewer.