Added umask so we don't have to change permissions every time.

This commit is contained in:
Neil Edelman 2016-10-19 22:52:41 -04:00
parent c6923b3594
commit c2692aa3aa
1 changed files with 13 additions and 4 deletions

View File

@ -1,13 +1,17 @@
/* Copyright 2008, 2012 Neil Edelman, distributed under the terms of the
GNU General Public License, see copying.txt */
/** Copyright 2008, 2012 Neil Edelman, distributed under the terms of the
GNU General Public License, see copying.txt
/* This is the main program. I didn't know what to call it.
* Created by Neil Edelman on 2008-03-27. */
This is the main program. I didn't know what to call it.
@author Neil
@version 1.0; 2016-09-19 Added umask
@since 1.0; 2008-03-27 */
#include <stdlib.h> /* malloc free fgets */
#include <stdio.h> /* fprintf FILE */
#include <string.h> /* strcmp */
#include <unistd.h> /* chdir (POSIX, not ANSI) */
#include <sys/stat.h> /* umask */
#include "Files.h"
#include "Widget.h"
#include "Parser.h"
@ -126,10 +130,15 @@ void Recursor_(void) {
/* entry-point (shouldn't have a prototype) */
int main(int argc, char **argv) {
int ret;
/* set up; fixme: dangerous! use stdarg, have a -delete, -write, and -help */
if(argc <= 1) { usage(argv[0]); return EXIT_SUCCESS; }
fprintf(stderr, "Changing directory to <%s>.\n", argv[1]);
if(chdir(argv[1])) { perror(argv[1]); return EXIT_FAILURE; }
/* make sure that umask is set so that others can read what we create */
umask(S_IWGRP | S_IWOTH);
/* recursing; fixme: this should be configurable */
if(!Recursor(tmplIndex, tmplSitemap, tmplNewsfeed)) return EXIT_FAILURE;
ret = recurse(0);