Ejemplo n.º 1
0
Archivo: help.c Proyecto: pexip/os-dpkg
static void
post_script_tasks(void)
{
  ensure_diversions();

  debug(dbg_triggersdetail,
        "post_script_tasks - ensure_diversions; trig_incorporate");
  trig_incorporate(msdbrw_write);
}
Ejemplo n.º 2
0
Archivo: help.c Proyecto: pexip/os-dpkg
void
post_postinst_tasks_core(struct pkginfo *pkg)
{
  modstatdb_note(pkg);

  if (!f_noact) {
    debug(dbg_triggersdetail, "post_postinst_tasks_core - trig_incorporate");
    trig_incorporate(msdbrw_write);
  }
}
Ejemplo n.º 3
0
enum modstatdb_rw
modstatdb_open(enum modstatdb_rw readwritereq)
{
    modstatdb_init();

    cflags = readwritereq & msdbrw_available_mask;
    readwritereq &= ~msdbrw_available_mask;

    switch (readwritereq) {
    case msdbrw_needsuperuser:
    case msdbrw_needsuperuserlockonly:
        if (getuid() || geteuid())
            ohshit(_("requested operation requires superuser privilege"));
    /* Fall through. */
    case msdbrw_write:
    case msdbrw_writeifposs:
        if (access(dpkg_db_get_dir(), W_OK)) {
            if (errno != EACCES)
                ohshite(_("unable to access dpkg status area"));
            else if (readwritereq == msdbrw_write)
                ohshit(_("operation requires read/write access to dpkg status area"));
            cstatus= msdbrw_readonly;
        } else {
            modstatdb_lock();
            cstatus= (readwritereq == msdbrw_needsuperuserlockonly ?
                      msdbrw_needsuperuserlockonly :
                      msdbrw_write);
        }
        break;
    case msdbrw_readonly:
        cstatus= msdbrw_readonly;
        break;
    default:
        internerr("unknown modstatdb_rw '%d'", readwritereq);
    }

    dpkg_arch_load_list();

    if (cstatus != msdbrw_needsuperuserlockonly) {
        cleanupdates();
        if (cflags >= msdbrw_available_readonly)
            parsedb(availablefile, pdb_parse_available, NULL);
    }

    if (cstatus >= msdbrw_write) {
        createimptmp();
        varbuf_init(&uvb, 10240);
    }

    trig_fixup_awaiters(cstatus);
    trig_incorporate(cstatus);

    return cstatus;
}
Ejemplo n.º 4
0
enum modstatdb_rw modstatdb_init(const char *adir, enum modstatdb_rw readwritereq) {
  const struct fni *fnip;
  
  admindir= adir;

  for (fnip=fnis; fnip->suffix; fnip++) {
    free(*fnip->store);
    *fnip->store= m_malloc(strlen(adir)+strlen(fnip->suffix)+2);
    sprintf(*fnip->store, "%s/%s", adir, fnip->suffix);
  }

  cflags= readwritereq & msdbrw_flagsmask;
  readwritereq &= ~msdbrw_flagsmask;

  switch (readwritereq) {
  case msdbrw_needsuperuser:
  case msdbrw_needsuperuserlockonly:
    if (getuid() || geteuid())
      ohshit(_("requested operation requires superuser privilege"));
    /* fall through */
  case msdbrw_write: case msdbrw_writeifposs:
    if (access(adir,W_OK)) {
      if (errno != EACCES)
        ohshite(_("unable to access dpkg status area"));
      else if (readwritereq == msdbrw_write)
        ohshit(_("operation requires read/write access to dpkg status area"));
      cstatus= msdbrw_readonly;
    } else {
      lockdatabase(adir);
      cstatus= (readwritereq == msdbrw_needsuperuserlockonly ?
                msdbrw_needsuperuserlockonly :
                msdbrw_write);
    }
    break;
  case msdbrw_readonly:
    cstatus= msdbrw_readonly; break;
  default:
    internerr("unknown modstatdb_rw '%d'", readwritereq);
  }

  updatefnbuf= m_malloc(strlen(adir)+sizeof(UPDATESDIR)+IMPORTANTMAXLEN+5);
  strcpy(updatefnbuf,adir);
  strcat(updatefnbuf,"/" UPDATESDIR);
  updatefnrest= updatefnbuf+strlen(updatefnbuf);

  if (cstatus != msdbrw_needsuperuserlockonly) {
    cleanupdates();
    if(!(cflags & msdbrw_noavail))
    parsedb(availablefile,
            pdb_recordavailable|pdb_rejectstatus,
            NULL,NULL,NULL);
  }

  if (cstatus >= msdbrw_write) {
    createimptmp();
    varbufinit(&uvb, 10240);
  }

  trig_fixup_awaiters(cstatus);
  trig_incorporate(cstatus, admindir);

  return cstatus;
}