Code Search for Developers
 
 
  

chown.c from SME Web Application Framework at Krugle


Show chown.c syntax highlighted

/**
 * This program is used so that apache can set the owner and group
 * of the files that it creates to WWW_DATA_OWNER and WWW_DATA_GROUP.
 * Normally, only root can change the owner and group of a file, 
 * so, this program should be owned by root and it should have the
 * stiky bit (+s).
 * In order to reduce any security risks, it changes the owner of
 * a file only if it is currently owned by apache (which usually
 * means that it has been created by apache).
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#define MY_UID          500
#define APACHE_UID      48
#define WWW_DATA_OWNER  MY_UID
#define WWW_DATA_GROUP  APACHE_UID

int main(int argc, char**argv)
{
  size_t n=0;
  char *filename;
  struct stat *file_stats;
  uid_t file_uid;

  /* check that it has been called by apache or by me */
  n = getuid();
  //if(n!=APACHE_UID && n!=MY_UID) exit(-1);

  /* check that there is only one argument */
  if (argc!=2) exit(-1);

  //get the filename
  n = strlen(argv[1]);
  filename = malloc(n+1);
  *filename = 0;
  strcat(filename, argv[1]);

  /* check that the file is owned by apache or by me */
  //stat(filename, file_stats);
  //file_uid = file_stats->st_uid;
  //if (file_uid!=APACHE_UID && file_uid!=MY_UID)  exit(-1);

  /* change the file owner */
  return chown(filename, WWW_DATA_OWNER, WWW_DATA_GROUP);
}





See more files for this project here

SME Web Application Framework

smewebapp intends to simplify the construction of web applications for informatization of the work of SME-s (small and medium enterprises), institutions, organizations etc.

Project homepage: http://sourceforge.net/projects/smewebapp
Programming language(s): JavaScript,PHP,Shell Script,XML
License: other

  codedoc/
    README.txt
    doxygen.cfg
    generate-code-doc.sh
    index.html
    phpdoc_html.sh
    phpdoc_pdf.sh
  config/
    const.DB.php
    const.Debug.php
    const.Options.php
    const.Paths.php
  css/
    print/
      button.css
      filter.css
      form.css
      hidden_submit.css
      list.css
      print.css
    button.css
    filter.css
    form.css
    hidden_submit.css
    list.css
    main.css
    selection.css
  db/
    backup.sh
    create.sh
    dump.sh
    dump_tables.sh
    init.sh
    menushpk-tables.sql
    menushpk.sql
    restore.sh
  docs/
    UML_Model/
      UML_Model.xmi
      aktivitetet.png
      database_diagram.png
      database_fields.png
      modeli_biznesit.png
    etags/
      etags.sh
      web_app.etags
    external/
      README.txt
      doxygen.cfg
      phpdoc.sh
    uml_model_png/
      database_diagrams/
        magazina.png
        skema_llogjike.png
        tabelat_kryesore.png
        tabelat_ndihmese.png
      logical_design/
        buletinet.png
        buletinet_klasat.png
        koeficientet.png
        magazina.png
        modulet_kryesore.png
        rpt_punet.png
        shpenzimet.png
      usecase_diagrams/
        administratori.png
        financieri.png
        magazinieri.png
        normisti.png
        perdoruesit.png
        pronari.png
        teknologu.png
        user.png
    changes.txt
    conventions.txt
    creating-a-new-app.txt
    doc.txt
    misc-notes.txt
    modules.txt
    tree.sh
    uml_model.xmi
  graphics/
    blue_triangle.png
    header_background.png
    pixel.png
  initial-modules/
    admin/
    documents/
    inventory/
    reports/
    tables/
    README
    config.sh
    create-modules.sh
    init-module.sh
    update-module.sh
    update-modules.sh
  l10n/
    compendia/
    en/
    sq_AL/
    README
    compendium-sq_AL.po
    get_app_name.sh
    menushpk.po
    msgcat.sh
    msgfmt.sh
    msginit.sh
    msgmerge.sh
    xgettext.sh
  module-templates/
    documents/
    edit_form/
    filter_1/
    filter_2/
    input_form/
    items/
    items_1/
    items_2/
    list/
    logs/
    pdf_document/
    simple_input_form/
    summary_report/
    tables/
    users/
    README
  modules/
    admin/
    documents/
    etc/
    filter/
    help/
    inventory/
    language/
    login/
    main/
  tools/
  upload/
  webobjects/
  COPYING
  INSTALL
  ToDo.txt
  browse.php
  chown.c
  chown.sh
  global.php
  index.php
  init.php
  install.sh
  upload-backup.php
  webapp.php