From owner-p4-projects@FreeBSD.ORG Fri Aug 20 07:35:09 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CBE3C10656A6; Fri, 20 Aug 2010 07:35:09 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C97A10656A4 for ; Fri, 20 Aug 2010 07:35:09 +0000 (UTC) (envelope-from dforsyth@FreeBSD.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 5F5D18FC20 for ; Fri, 20 Aug 2010 07:35:08 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id o7K7Z8Tc031000 for ; Fri, 20 Aug 2010 07:35:08 GMT (envelope-from dforsyth@FreeBSD.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id o7K7Z80x030997 for perforce@freebsd.org; Fri, 20 Aug 2010 07:35:08 GMT (envelope-from dforsyth@FreeBSD.org) Date: Fri, 20 Aug 2010 07:35:08 GMT Message-Id: <201008200735.o7K7Z80x030997@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to dforsyth@FreeBSD.org using -f From: David Forsythe To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 182645 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2010 07:35:10 -0000 http://p4web.freebsd.org/@@182645?ac=10 Change 182645 by dforsyth@skunk on 2010/08/20 07:34:42 A few of the changes Tim suggested. This is the main libpkg repository now. Affected files ... .. //depot/projects/soc2010/dforsyth_libpkg/doc/man/pkg_database.3#1 add .. //depot/projects/soc2010/dforsyth_libpkg/doc/man/pkg_freebsd.3#1 add .. //depot/projects/soc2010/dforsyth_libpkg/doc/man/pkg_repository.3#1 add .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/Makefile#3 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/base.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/database_internal.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec_internal.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_database_directorydb.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_database_directorydb.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_plist.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_plist.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_ftp.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_ftp.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_path.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_path.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/internal.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/logger.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/logger.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg.c#3 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg.h#3 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_freebsd.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_freebsd.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_internal.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_pkg.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/property.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/property.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository_internal.h#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/util.c#2 edit .. //depot/projects/soc2010/dforsyth_libpkg/libpkg/util.h#2 edit Differences ... ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/Makefile#3 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/base.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.c#2 (text+ko) ==== @@ -49,17 +49,20 @@ } /* Release a package database from memory. */ -void +int pkg_database_release(struct pkg_database *db) { _pkg_database_check_magic(db, __func__); if (db->status != CLOSED) { - warnx("closing pkg_database before free()"); - db->vtable->close(db); + if (db->vtable->close(db) != PKG_OK) { + warnx("db->vtable->close() failed."); + return (PKG_NOT_OK); + } } + free(db); - free(db); + return (PKG_OK); } void @@ -169,8 +172,7 @@ _pkg_check_magic(p, __func__); if (db->status != OPEN) { - /* Just leave. */ - return (PKG_NOT_OK); + PKG_CLIENT_CRASH(__func__, "db->status != OPEN"); } /* Log this action. */ /* ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.h#2 (text+ko) ==== @@ -15,7 +15,9 @@ struct pkg_database *pkg_database_create(void); -void pkg_database_release(struct pkg_database *); +int pkg_database_release(struct pkg_database *); + +uid_t pkg_database_owner(struct pkg_database *); /* Get the next package in a database. */ int pkg_database_get_next_pkg(struct pkg_database *, struct pkg *, u_int); ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/database_internal.h#2 (text+ko) ==== @@ -16,6 +16,7 @@ int (*get_pkg) (struct pkg_database *, struct pkg *, u_int); int (*rewind) (struct pkg_database *); int (*open) (struct pkg_database *, const char *, u_int); + uid_t (*owner) (struct pkg_database *); }; /* Define the package database type. */ ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec_internal.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_database_directorydb.c#2 (text+ko) ==== @@ -26,6 +26,7 @@ static int _write_pkg(struct pkg_database *, struct pkg *, u_int); static int _pkg_database_directorydb_open(struct pkg_database *, const char *, u_int); +static uid_t _pkg_database_directorydb_owner(struct pkg_database *); static int _pkg_database_directorydb_rewind(struct pkg_database *); static int _pkg_database_directorydb_close(struct pkg_database *); static int _pkg_database_directorydb_add_pkg(struct pkg_database *, @@ -41,7 +42,8 @@ .add_pkg = _pkg_database_directorydb_add_pkg, .remove_pkg = _pkg_database_directorydb_remove_pkg, .rewind = _pkg_database_directorydb_rewind, - .get_next_pkg = _pkg_database_directorydb_get_next_pkg + .get_next_pkg = _pkg_database_directorydb_get_next_pkg, + .owner = _pkg_database_directorydb_owner }; @@ -74,6 +76,20 @@ return ("directorydb"); } +static uid_t +_pkg_database_directorydb_owner(struct pkg_database *db) +{ + struct _directorydb *d; + struct stat sb; + + d = db->internal; + if (d == NULL || lstat(d->location[0], &sb) < 0) { + return (-1); + } + + return (sb.st_uid); +} + static int _pkg_database_directorydb_open(struct pkg_database *db, const char *path, u_int flags) ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_database_directorydb.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_plist.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_plist.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_ftp.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_ftp.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_path.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_path.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/internal.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/logger.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/logger.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg.c#3 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg.h#3 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_freebsd.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_freebsd.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_internal.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_pkg.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/property.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/property.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository_internal.h#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/util.c#2 (text+ko) ==== ==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/util.h#2 (text+ko) ====