Skip to content

Commit

Permalink
Merge branch 'master' of github.com:comotion/cpm
Browse files Browse the repository at this point in the history
  • Loading branch information
comotion committed Oct 9, 2013
2 parents c11fe36 + b14a86a commit 4bb17f3
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 28 deletions.
11 changes: 11 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H

/* Define to 1 if you have the <sys/prctl.h> header file. */
#undef HAVE_SYS_PRCTL_H

/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

Expand Down Expand Up @@ -167,6 +170,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME

/* Define to the home page for this package. */
#undef PACKAGE_URL

/* Define to the version of this package. */
#undef PACKAGE_VERSION

Expand All @@ -179,6 +185,11 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME

/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif

/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS

Expand Down
30 changes: 21 additions & 9 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for cpm 0.27.
# Generated by GNU Autoconf 2.69 for cpm 0.28.
#
# Report bugs to <[email protected]>.
#
Expand Down Expand Up @@ -548,8 +548,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cpm'
PACKAGE_TARNAME='cpm'
PACKAGE_VERSION='0.27'
PACKAGE_STRING='cpm 0.27'
PACKAGE_VERSION='0.28'
PACKAGE_STRING='cpm 0.28'
PACKAGE_BUGREPORT='[email protected]'
PACKAGE_URL=''

Expand Down Expand Up @@ -1226,7 +1226,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cpm 0.27 to adapt to many kinds of systems.
\`configure' configures cpm 0.28 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1287,7 +1287,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cpm 0.27:";;
short | recursive ) echo "Configuration of cpm 0.28:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1392,7 +1392,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cpm configure 0.27
cpm configure 0.28
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1815,7 +1815,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cpm $as_me 0.27, which was
It was created by cpm $as_me 0.28, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -4633,6 +4633,18 @@ fi

done

for ac_header in sys/prctl.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sys/prctl.h" "ac_cv_header_sys_prctl_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_prctl_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SYS_PRCTL_H 1
_ACEOF

fi

done


# Checks for typedefs, structures, and compiler characteristics.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking typedefs, structures, and compiler characteristics" >&5
Expand Down Expand Up @@ -6300,7 +6312,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cpm $as_me 0.27, which was
This file was extended by cpm $as_me 0.28, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -6362,7 +6374,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
cpm config.status 0.27
cpm config.status 0.28
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down
3 changes: 2 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

AC_MSG_NOTICE([general setup])
AC_PREREQ(2.59)
AC_INIT(cpm, 0.27, [email protected])
AC_INIT(cpm, 0.28, [email protected])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])

Expand Down Expand Up @@ -372,6 +372,7 @@ AC_SUBST(LIBGPGME_CFLAGS)
AC_MSG_NOTICE([checking header files])
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h getopt.h libintl.h locale.h stdlib.h sys/fsuid.h sys/ioctl.h termios.h])
AC_CHECK_HEADERS(sys/prctl.h)

# Checks for typedefs, structures, and compiler characteristics.
AC_MSG_NOTICE([checking typedefs, structures, and compiler characteristics])
Expand Down
9 changes: 6 additions & 3 deletions cpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
#include "config.h"
#define _GNU_SOURCE

#ifdef HAVE_STDLIB_H
#ifndef _SVID_SOURCE
#define _SVID_SOURCE
#endif
#include <stdlib.h>
#endif
#include <errno.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
Expand All @@ -43,9 +49,6 @@
#endif
#include <signal.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRINGS_H
#include <string.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ int getInfodataLength(void)
return max_x;
else
return STDBUFFERLENGTH;
(void)max_y; // remove unused var warning
}


Expand Down Expand Up @@ -1337,6 +1338,7 @@ int guiDialogHandleKeys(EObjectType cdktype, void* object, void* clientdata,
while (!done);

return 1;
(void) selection; // unused
}


Expand Down
2 changes: 0 additions & 2 deletions interface_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ void initXMLInterface(void)
xmlNode* nodeFind(char* label)
{
xmlNode* curnode;
xmlNode* newnode;
char* prop;

TRACE(99, "nodeFind()", NULL);
Expand All @@ -392,7 +391,6 @@ xmlNode* nodeFind(char* label)
{ return 0; }

curnode = xmlwalklist[level - 1] -> children;
newnode = NULL;
while (curnode)
{
if (curnode -> type == XML_ELEMENT_NODE &&
Expand Down
10 changes: 5 additions & 5 deletions memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ long int memorycounter = 0;
*/
void* memDebugAlloc(const char* file, int line, size_t size)
{
fprintf(stderr, "alloc %5d (%s, line %d)\n", size, file, line);
fprintf(stderr, "alloc %5lu (%s, line %d)\n", size, file, line);
return memRealAlloc(size);
}

Expand All @@ -59,7 +59,7 @@ void* memDebugAlloc(const char* file, int line, size_t size)
*/
void memDebugFree(const char* file, int line, void* ptr, size_t size)
{
fprintf(stderr, "free %5d (%s, line %d)\n", size, file, line);
fprintf(stderr, "free %5lu (%s, line %d)\n", size, file, line);
memRealFree(ptr, size);
}

Expand All @@ -76,7 +76,7 @@ void memDebugFreeString(const char* file, int line, void* ptr)
{
if (ptr)
{
fprintf(stderr, "free %5d (%s, line %d)\n",
fprintf(stderr, "free %5zd (%s, line %d)\n",
strlen(ptr) + 1, file, line);
}

Expand Down Expand Up @@ -118,7 +118,7 @@ void* memRealAlloc(size_t size)
ptr = malloc(size);
if (!ptr)
{
fprintf(stderr, _("out of memory error - tried to allocate %d byte.\n"),
fprintf(stderr, _("out of memory error - tried to allocate %lu byte.\n"),
size);
exit(1);
}
Expand Down Expand Up @@ -200,7 +200,7 @@ void* memRealRealloc(void* ptr, size_t size_old, size_t size_new)
if (!ptr)
{
fprintf(stderr,
_("out of memory error - tried to reallocate %d byte.\n"),
_("out of memory error - tried to reallocate %lu byte.\n"),
size_new);
exit(1);
}
Expand Down
18 changes: 11 additions & 7 deletions security.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
/* #############################################################################
* includes
*/
#include <sys/utsname.h>

#include "cpm.h"
#include <sys/utsname.h>
#if defined(HAVE_SYS_PRCTL_H)
#include <sys/ptrace.h>
#include <sys/prctl.h>
#endif
#include <sys/types.h>
#include <sys/wait.h>
#include <regex.h>
Expand Down Expand Up @@ -495,7 +498,7 @@ int initSecurity(int* max_mem_lock, int* memory_safe, int* ptrace_safe,
*memory_safe = 0;
*ptrace_safe = 0;

#ifdef _SYS_PTRACE_H
#if defined(_SYS_PTRACE_H) && !defined(TRACE_DEBUG)
/* Try to fork a child which then ptrace attaches to it's parent
* This will safely prevent other processes (even root) to be able to attach to us */
{
Expand All @@ -510,20 +513,22 @@ int initSecurity(int* max_mem_lock, int* memory_safe, int* ptrace_safe,
}

if (p == 0) {
#if defined(HAVE_SYS_PRCTL_H)
// makes the child unattachable
if (prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) != 0) {
fprintf(stderr, "Can not set child non dumpable\n");
_exit(1);
}
#endif

if (ptrace(PTRACE_ATTACH, p0, 0, 0) != 0) {
if (ptrace(PT_ATTACH, p0, 0, 0) != 0) {
// someone is already attached to us; shoot the parent in the head
fprintf(stderr, "Can't attach to parent!\n");
kill(p0, SIGKILL);
_exit(1);
}
while (1) {
if(ptrace(PTRACE_SYSCALL, p0, 0, 0) == 0)
if(ptrace(PT_SYSCALL, p0, 0, 0) == 0)
waitpid(p0, &status, 0);
if(errno == ESRCH && kill(p0, 0) == -1)
exit(0); // parent is dead
Expand Down Expand Up @@ -711,10 +716,9 @@ int initSecurity(int* max_mem_lock, int* memory_safe, int* ptrace_safe,
/* NOTE: no file must be opened before this test! */
canary = dup(0);
close(canary);
if (canary != 3)
if (canary < 3)
{
fprintf(stderr, "%s\n",
_("stdin, stdout and/or stderr are invalid."));
fprintf(stderr, "%s\n", _("stdin, stdout and/or stderr are invalid."));
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/encrypt-result.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
<!ATTLIST user uid CDATA #REQUIRED>
<!ATTLIST user created-on CDATA #REQUIRED>
]>
<root version="0.25beta2"><editor><user uid="1">unknown</user></editor><template/></root>
<root version="0.28"><editor><user uid="1">unknown</user></editor><template/></root>

0 comments on commit 4bb17f3

Please sign in to comment.