From owner-svn-soc-all@FreeBSD.ORG Tue Sep 10 18:57:50 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0D44E5B0 for ; Tue, 10 Sep 2013 18:57:50 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DFD1A22C1 for ; Tue, 10 Sep 2013 18:57:49 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8AIvnpa090196 for ; Tue, 10 Sep 2013 18:57:49 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8AIvnlA090188 for svn-soc-all@FreeBSD.org; Tue, 10 Sep 2013 18:57:49 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 10 Sep 2013 18:57:49 GMT Message-Id: <201309101857.r8AIvnlA090188@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257199 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Sep 2013 18:57:50 -0000 Author: dpl Date: Tue Sep 10 18:57:49 2013 New Revision: 257199 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257199 Log: Finally xz is working as it should. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Tue Sep 10 17:26:09 2013 (r257198) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Tue Sep 10 18:57:49 2013 (r257199) @@ -12,6 +12,10 @@ #include "private.h" +#ifdef CAPSICUM +# include +#endif + #include #ifdef TUKLIB_DOSLIKE @@ -993,7 +997,7 @@ // Set and possibly print the filename for the progress message. message_filename(filename[i]); - if (opt_mode == MODE_LIST) { + if (opt_mode == MODE_LIST) { if (filename[i] == stdin_filename) { message_error(_("--list does not support reading from " "standard input")); @@ -1026,25 +1030,24 @@ cap_rights_t rights; if(pair->dir_fd != -1 ){ - rights = CAP_FSTATAT|CAP_UNLINKAT|CAP_LOOKUP; - if (cap_rights_limit(pair->dir_fd, rights) < 0 && errno != ENOSYS){ + cap_rights_init(&rights, CAP_FSTATAT, CAP_UNLINKAT, CAP_LOOKUP); + if (cap_rights_limit(pair->dir_fd, &rights) < 0 && errno != ENOSYS){ message_error("%s: %s", pair->dest_name, strerror(errno)); exit(E_ERROR); } } if(pair->src_fd != -1 ){ - rights = CAP_READ|CAP_SEEK; - if (cap_rights_limit(pair->src_fd, rights) < 0 && errno != ENOSYS){ + cap_rights_init(&rights, CAP_READ, CAP_SEEK); + if (cap_rights_limit(pair->src_fd, &rights) < 0 && errno != ENOSYS){ message_error("%s: %s", pair->src_name, strerror(errno)); exit(E_ERROR); } } if(pair->dest_fd != -1 ){ - rights = CAP_WRITE|CAP_FSTAT|CAP_FCHOWN - |CAP_FCHMOD|CAP_FUTIMES; - if (cap_rights_limit(pair->dest_fd, rights) < 0 && errno != ENOSYS){ + cap_rights_init(&rights, CAP_WRITE, CAP_FSTAT, CAP_FCHOWN, CAP_FCHMOD, CAP_FUTIMES); + if (cap_rights_limit(pair->dest_fd, &rights) < 0 && errno != ENOSYS){ message_error("%s: %s", pair->dest_name, strerror(errno)); exit(E_ERROR); } @@ -1055,29 +1058,33 @@ extern void capsicum_enter(void) { - cap_rights_t rights; + cap_rights_t stdin_cap; + cap_rights_t write_cap; - if( cap_rights_get(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) { + cap_rights_init(&stdin_cap, CAP_READ); + cap_rights_init(&write_cap, CAP_WRITE); + +/* if( cap_rights_get(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) { message_error("%d: %s", STDIN_FILENO, strerror(errno)); exit(E_ERROR); - } else if (rights == 0) { - if (cap_rights_limit(STDIN_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + } else if (rights == 0) {*/ + if (cap_rights_limit(STDIN_FILENO, &stdin_cap) < 0 && errno != ENOSYS){ message_error("%d: %s", STDIN_FILENO, strerror(errno)); exit(E_ERROR); } - } + //} - if( cap_rights_get(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) { +/* if( cap_rights_get(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) { message_error("%d: %s", STDOUT_FILENO, strerror(errno)); exit(E_ERROR); - } else if (rights == 0) { - if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + } else if (rights == 0) { */ + if (cap_rights_limit(STDOUT_FILENO, &write_cap) < 0 && errno != ENOSYS){ message_error("%d: %s", STDOUT_FILENO, strerror(errno)); exit(E_ERROR); } - } + //} - if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + if (cap_rights_limit(STDERR_FILENO, &write_cap) < 0 && errno != ENOSYS){ message_error("%d: %s", STDERR_FILENO, strerror(errno)); exit(E_ERROR); } Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Tue Sep 10 17:26:09 2013 (r257198) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Tue Sep 10 18:57:49 2013 (r257199) @@ -144,8 +144,7 @@ int forkpid, i, nfiles=0; //Filenames will be here, and get passed to io_open_files(). // If we get past of 8 elements, realloc 8 more. - // XXX check - char **files = malloc( 8*sizeof(char*) ); + char **files = malloc(8*sizeof(char*)); if (files == NULL) { message_error("malloc: %s", strerror(errno)); exit(E_ERROR); @@ -253,9 +252,8 @@ // This way error messages get a proper filename // string and the code still knows that it is // handling the special case of stdin. - size_t len = strlen(stdin_filename)+1; - files[i] = malloc(len); - strncpy(files[i], stdin_filename, len); + args.arg_names[i] = (char *)stdin_filename; + files[i] = (char *)stdin_filename; } else { size_t len = strlen(args.arg_names[i])+1; files[i] = malloc(len);