From: Kern Sibbald Date: Mon, 10 Jul 2006 20:09:17 +0000 (+0000) Subject: - Add Enabled column to Location, correct some typos in DB schemas. X-Git-Tag: Release-7.0.0~7877 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c2d212a329778e22987d38efb820e162141b5f27;p=bacula%2Fbacula - Add Enabled column to Location, correct some typos in DB schemas. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3136 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index 14576d006b..06aa058c64 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -3,6 +3,7 @@ General: 10Jul06 +- Add Enabled column to Location, correct some typos in DB schemas. - Correct bug I introduced into RunScripts enum. - Add log table to Catalog - Purge original job migrated if the migration terminates normally. diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index d2319f49c4..8ce92132c0 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -119,6 +119,7 @@ CREATE TABLE Location ( LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Location TINYBLOB NOT NULL, Cost INTEGER DEFAULT 0, + Enabled TINYINT, PRIMARY KEY(LocationId) ); diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index 9641cd3da5..261227bd26 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -82,6 +82,7 @@ CREATE TABLE Location ( LocationId serial not null, Location text not null, Cost integer default 0, + Enabled smallint, primary key (LocationId) ); diff --git a/bacula/src/cats/make_sqlite3_tables.in b/bacula/src/cats/make_sqlite3_tables.in index 3838ec3108..7e49d713a2 100644 --- a/bacula/src/cats/make_sqlite3_tables.in +++ b/bacula/src/cats/make_sqlite3_tables.in @@ -78,7 +78,8 @@ CREATE INDEX inx6 ON Job (Name); CREATE TABLE Location ( LocationId INTEGER, Location TINYBLOB NOT NULL, - Cost INTEGER, + Cost INTEGER DEFAULT 0, + Enabled TINYINT, PRIMARY KEY(LocationId) ); diff --git a/bacula/src/cats/make_sqlite_tables.in b/bacula/src/cats/make_sqlite_tables.in index 3838ec3108..7e49d713a2 100644 --- a/bacula/src/cats/make_sqlite_tables.in +++ b/bacula/src/cats/make_sqlite_tables.in @@ -78,7 +78,8 @@ CREATE INDEX inx6 ON Job (Name); CREATE TABLE Location ( LocationId INTEGER, Location TINYBLOB NOT NULL, - Cost INTEGER, + Cost INTEGER DEFAULT 0, + Enabled TINYINT, PRIMARY KEY(LocationId) ); diff --git a/bacula/src/cats/update_mysql_tables.in b/bacula/src/cats/update_mysql_tables.in index 7008e38cc1..c59e46f86e 100755 --- a/bacula/src/cats/update_mysql_tables.in +++ b/bacula/src/cats/update_mysql_tables.in @@ -36,6 +36,7 @@ CREATE TABLE Location ( LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Location TINYBLOB NOT NULL, Cost INTEGER DEFAULT 0, + Enabled TINYINT, PRIMARY KEY(LocationId) ); diff --git a/bacula/src/cats/update_postgresql_tables.in b/bacula/src/cats/update_postgresql_tables.in index 03b8ee8ca0..afb05793e6 100755 --- a/bacula/src/cats/update_postgresql_tables.in +++ b/bacula/src/cats/update_postgresql_tables.in @@ -38,7 +38,8 @@ ALTER TABLE jobmedia DROP COLUMN Stripe; CREATE TABLE Location ( LocationId SERIAL NOT NULL, Location TEXT NOT NULL, - Cost integer not null default 0, + Cost integer default 0, + Enabled integer, PRIMARY KEY (LocationId) ); diff --git a/bacula/src/cats/update_sqlite3_tables.in b/bacula/src/cats/update_sqlite3_tables.in index b40c9a8bcc..399497bae0 100755 --- a/bacula/src/cats/update_sqlite3_tables.in +++ b/bacula/src/cats/update_sqlite3_tables.in @@ -222,7 +222,8 @@ CREATE TABLE Log CREATE TABLE Location ( LocationId INTEGER, Location VARCHAR(128) NOT NULL, - Counter INTEGER DEFAULT 0, + Cost INTEGER DEFAULT 0, + Enabled TINYINT, PRIMARY KEY(LocationId) ); diff --git a/bacula/src/cats/update_sqlite_tables.in b/bacula/src/cats/update_sqlite_tables.in index b40c9a8bcc..399497bae0 100755 --- a/bacula/src/cats/update_sqlite_tables.in +++ b/bacula/src/cats/update_sqlite_tables.in @@ -222,7 +222,8 @@ CREATE TABLE Log CREATE TABLE Location ( LocationId INTEGER, Location VARCHAR(128) NOT NULL, - Counter INTEGER DEFAULT 0, + Cost INTEGER DEFAULT 0, + Enabled TINYINT, PRIMARY KEY(LocationId) ); diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index 86b437f073..9b0dd5f624 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -621,6 +621,8 @@ void drop(char *uname, char *gname) struct passwd *passw = NULL; struct group *group = NULL; gid_t gid; + uid_t uid; + char username[1000]; Dmsg2(900, "uname=%s gname=%s\n", uname?uname:"NONE", gname?gname:"NONE"); if (!uname && !gname) { @@ -642,6 +644,10 @@ void drop(char *uname, char *gname) uname = passw->pw_name; } } + /* Any OS uname pointer may get overwritten, so save name, uid, and gid */ + bstrncpy(username, uname, sizeof(username)); + uid = passw->pw_uid; + gid = passw->pw_gid; if (gname) { if ((group = getgrnam(gname)) == NULL) { berrno be; @@ -649,29 +655,27 @@ void drop(char *uname, char *gname) be.strerror()); } gid = group->gr_gid; - } else { - gid = passw->pw_gid; } - if (initgroups(passw->pw_name, passw->pw_gid)) { + if (initgroups(username, gid)) { berrno be; if (gname) { Emsg3(M_ERROR_TERM, 0, _("Could not initgroups for group=%s, userid=%s: ERR=%s\n"), - gname, uname, be.strerror()); + gname, username, be.strerror()); } else { Emsg2(M_ERROR_TERM, 0, _("Could not initgroups for userid=%s: ERR=%s\n"), - uname, be.strerror()); + username, be.strerror()); } } if (gname) { - if (setgid(group->gr_gid)) { + if (setgid(gid)) { berrno be; Emsg2(M_ERROR_TERM, 0, _("Could not set group=%s: ERR=%s\n"), gname, be.strerror()); } } - if (setuid(passw->pw_uid)) { + if (setuid(uid)) { berrno be; - Emsg1(M_ERROR_TERM, 0, _("Could not set specified userid: %s\n"), uname); + Emsg1(M_ERROR_TERM, 0, _("Could not set specified userid: %s\n"), username); } #endif }