+Tue Nov 16 13:18:53 WST 2004 John Darrington <john@darrington.wattle.id.au>
+
+ * utilities.texi Added documentation for the PERMISSIONS command.
+
+ * pspp.texinfo Makefile.am @included version.texi (Autogenerated) to
+ keep the EDITION, VERSION and UPDATED flags up to date.
+
Tue Nov 9 09:38:43 WST 2004 John Darrington <john@darrington.wattle.id.au>
* Made Makefile.am aware of pspp.texi dependencies
info_TEXINFOS = pspp.texinfo
-pspp_TEXINFOS = \
+pspp_TEXINFOS = version.texi \
bugs.texi \
command-index.texi \
concept-index.texi \
@setfilename pspp.info
@settitle PSPP
@set TIMESTAMP Time-stamp: Sat Oct 30 17:30:39 WST 2004
-@set EDITION 0.21
-@set VERSION 0.31
@c For double-sided printing, uncomment:
@c @setchapternewpage odd
@c %**end of header
translation approved by the Free Software Foundation.
@end ifinfo
+@include version.texi
+
@titlepage
@title PSPP
@subtitle A System for Statistical Analysis
@contents
+
@node Top, Introduction, (dir), (dir)
@ifinfo
@top PSPP
* FINISH:: Terminate the PSPP session.
* HOST:: Temporarily return to the operating system.
* INCLUDE:: Include a file within the current one.
+* PERMISSIONS:: Change permissions on a file.
* QUIT:: Terminate the PSPP session.
* SET:: Adjust PSPP runtime parameters.
* SHOW:: Display runtime parameters.
This command cannot be used if the SAFER setting is active.
-@node INCLUDE, QUIT, HOST, Utilities
+@node INCLUDE, PERMISSIONS, HOST, Utilities
@section INCLUDE
@vindex INCLUDE
@vindex @@
Include files may be nested to any depth, up to the limit of available
memory.
-@node QUIT, SET, INCLUDE, Utilities
+@node PERMISSIONS, QUIT, INCLUDE, Utilities
+@comment node-name, next, previous, up
+@section PERMISSIONS
+@vindex PERMISSIONS
+@cindex mode
+@cindex file mode
+@cindex changing file permissions
+
+@display
+PERMISSIONS
+ FILE='filename'
+ /PERMISSIONS = @{READONLY,WRITEABLE@}.
+@end display
+
+@cmd{PERMISSIONS} changes the permissions of a file.
+There is one mandatory subcommand which specifies the permissions to
+which the file should be changed.
+If you set a file's permission to READONLY, then the file will become
+unwritable either by you or anyone else on the system.
+If you set the permission to WRITEABLE, then the file will become
+writeable by you; the permissions afforded to others will be
+unchanged.
+
+
+@node QUIT, SET, PERMISSIONS, Utilities
@section QUIT
@vindex QUIT
+Tue Nov 16 13:19:18 WST 2004 John Darrington <john@darrington.wattle.id.au>
+
+ * permissions.c command.def Added the PERMISSIONS command
+
Mon Nov 15 01:33:32 2004 Ben Pfaff <blp@gnu.org>
* q2c.c: (dump_header) Don't try to emit #includes at very top of
hash.c hash.h html.c htmlP.h include.c inpt-pgm.c lexer.c \
lexer.h levene.c levene.h log.h loop.c magic.c magic.h main.c main.h \
matrix-data.c mis-val.c misc.c misc.h modify-vars.c \
-moments.c moments.h numeric.c output.c output.h pfm-read.c pfm-read.h \
+moments.c moments.h numeric.c output.c output.h permissions.c \
+pfm-read.c pfm-read.h \
pfm-write.c pfm-write.h \
pool.c pool.h postscript.c print.c random.c random.h recode.c \
rename-vars.c repeat.c repeat.h sample.c sel-if.c settings.h \
/* Plot a data point */
void
-chart_datum(struct chart *ch, int dataset, double x, double y)
+chart_datum(struct chart *ch, int dataset UNUSED, double x, double y)
{
const double x_pos =
(x - ch->x_min) * ch->abscissa_scale + ch->data_left ;
DEFCMD ("NUMERIC", ERRO, INPU, TRAN, TRAN, cmd_numeric)
UNIMPL ("UNNUMBERED", INIT, INPU, TRAN, PROC)
DEFCMD ("ONEWAY", ERRO, ERRO, PROC, PROC, cmd_oneway)
+DEFCMD ("PERMISSIONS", INIT, INPU, TRAN, PROC, cmd_permissions)
DEFCMD ("PEARSON CORRELATIONS", ERRO, ERRO, PROC, PROC, cmd_correlations)
UNIMPL ("POINT", ERRO, INPU, ERRO, ERRO)
UNIMPL ("PRESERVE", INIT, INPU, TRAN, PROC)
--- /dev/null
+/* PSPP - computes sample statistics.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Author: John Darrington
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <config.h>
+#include "error.h"
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "command.h"
+#include "error.h"
+#include "lexer.h"
+#include "misc.h"
+#include "str.h"
+
+
+
+enum PER {PER_RO, PER_RW};
+
+int change_permissions(const char *filename, enum PER per);
+
+
+/* Parses the PERMISSIONS command. */
+int
+cmd_permissions (void)
+{
+ char *fn = 0;
+
+ lex_match ('/');
+
+ if (lex_match_id ("FILE"))
+ lex_match ('=');
+
+ fn = strdup(ds_c_str(&tokstr));
+ lex_force_match(T_STRING);
+
+
+ lex_match ('/');
+
+ if ( ! lex_match_id ("PERMISSIONS"))
+ goto error;
+
+ lex_match('=');
+
+ if ( lex_match_id("READONLY"))
+ {
+ if ( ! change_permissions(fn, PER_RO ) )
+ goto error;
+ }
+ else if ( lex_match_id("WRITEABLE"))
+ {
+ if ( ! change_permissions(fn, PER_RW ) )
+ goto error;
+ }
+ else
+ {
+ msg(ME, _("Expecting %s or %s."), "WRITEABLE", "READONLY");
+ goto error;
+ }
+
+ free(fn);
+
+ return CMD_SUCCESS;
+
+ error:
+
+ free(fn);
+
+ return CMD_FAILURE;
+}
+
+
+
+int
+change_permissions(const char *filename, enum PER per)
+{
+ struct stat buf;
+ mode_t mode;
+
+ if ( -1 == stat(filename, &buf) )
+ {
+ const int errnum = errno;
+ msg(ME,_("Cannot stat %s: %s"), filename, strerror(errnum));
+ return 0;
+ }
+
+ if ( per == PER_RW )
+ mode = buf.st_mode | S_IWUSR ;
+ else
+ mode = buf.st_mode & ~( S_IWOTH | S_IWUSR | S_IWGRP );
+
+ if ( -1 == chmod(filename, mode))
+
+ {
+ const int errnum = errno;
+ msg(ME,_("Cannot change mode of %s: %s"), filename, strerror(errnum));
+ return 0;
+ }
+
+ return 1;
+}
command/oneway.sh \
command/oneway-missing.sh \
command/oneway-with-splits.sh \
+ command/permissions.sh \
command/print.sh \
command/sample.sh \
command/sort.sh \
--- /dev/null
+#!/bin/sh
+
+# This program tests the PERMISSIONS command
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+ rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+ echo $activity
+ echo FAILED
+ cleanup;
+ exit 1;
+}
+
+
+no_result()
+{
+ echo $activity
+ echo NO RESULT;
+ cleanup;
+ exit 2;
+}
+
+pass()
+{
+ cleanup;
+ exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+
+activity="Create file"
+echo HEllo > foobar
+chmod 777 foobar
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="Create program"
+cat > per.sps <<EOF
+PERMISSIONS /FILE='foobar'
+ PERMISSIONS = READONLY.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/per.sps
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="Check Permissions"
+ls -l foobar | grep '^-r-xr-xr-x' > /dev/null
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+activity="Create program"
+cat > per.sps <<EOF
+PERMISSIONS /FILE='foobar'
+ PERMISSIONS = WRITEABLE.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/per.sps
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="Check Permissions"
+ls -l foobar | grep '^-rwxr-xr-x' > /dev/null
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+
+pass;