From 50e7dd7d01de742006ebbac9322bc775d0f564a3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 10 Jun 2010 14:29:55 +0400 Subject: [PATCH] prevent default admin user from being removed; properly fail on startup if single user mode is enabled but default admin user is missing from the database --- modules/pref-users.php | 2 +- prefs.js | 2 +- sanity_check.php | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/pref-users.php b/modules/pref-users.php index a57178d6..aa0da88e 100644 --- a/modules/pref-users.php +++ b/modules/pref-users.php @@ -214,7 +214,7 @@ $ids = split(",", db_escape_string($_REQUEST["ids"])); foreach ($ids as $id) { - if ($id != $_SESSION["uid"]) { + if ($id != $_SESSION["uid"] && $id != 1) { db_query($link, "DELETE FROM ttrss_tags WHERE owner_uid = '$id'"); db_query($link, "DELETE FROM ttrss_feeds WHERE owner_uid = '$id'"); db_query($link, "DELETE FROM ttrss_users WHERE id = '$id'"); diff --git a/prefs.js b/prefs.js index 6d5e5a90..43e6b28b 100644 --- a/prefs.js +++ b/prefs.js @@ -465,7 +465,7 @@ function removeSelectedUsers() { if (sel_rows.length > 0) { - var ok = confirm(__("Remove selected users?")); + var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed.")); if (ok) { notify_progress("Removing selected users..."); diff --git a/sanity_check.php b/sanity_check.php index d112896e..d2f0e317 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -66,6 +66,18 @@ $err_msg = "config: DATABASE_BACKED_SESSIONS are currently broken with MySQL"; } + if (SINGLE_USER_MODE) { + $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); + + if ($link) { + $result = db_query($link, "SELECT id FROM ttrss_users WHERE id = 1"); + + if (db_num_rows($result) != 1) { + $err_msg = "config: SINGLE_USER_MODE is enabled but default admin account (UID=1) is not found."; + } + } + } + if (defined('MAIL_FROM')) { $err_msg = "config: MAIL_FROM has been split into DIGEST_FROM_NAME and DIGEST_FROM_ADDRESS"; } -- 2.39.5