if (ghelp) { cout << specific_help << endl; return !ghelp; }
// if (ghelp) display_command_help()
- //! \todo modify according to final decition on /etc/zypp/repos.d
- /*
- if ( geteuid() != 0 )
- {
- cerr << _("Root privileges are required for viewing system sources.") << endl;
- return ZYPPER_EXIT_ERR_PRIVILEGES;
- }*/
-
list_repos();
return ZYPPER_EXIT_OK;
}
else if (command == ZypperCommand::ADD_REPO)
{
+ if (ghelp)
+ {
+ cout << specific_help;
+ return ZYPPER_EXIT_OK;
+ }
+
+ // check root user
+ if (geteuid() != 0)
+ {
+ cerr << _("Root privileges are required for modifying system repositories.") << endl;
+ return ZYPPER_EXIT_ERR_PRIVILEGES;
+ }
+
tribool enabled(indeterminate);
tribool refresh(indeterminate);
string type = copts.count("type") ? copts["type"].front() : "";
// display help message if insufficient info was given
- if (ghelp || arguments.size() < 2)
+ if (arguments.size() < 2)
{
- if (ghelp)
- {
- cout << specific_help;
- return ZYPPER_EXIT_OK;
- }
- else
- {
- cerr << _("Too few arguments. At least URL and alias are required.") << endl;
- ERR << "Too few arguments. At least URL and alias are required." << endl;
- cout_n << specific_help;
- return ZYPPER_EXIT_ERR_INVALID_ARGS;
- }
+ cerr << _("Too few arguments. At least URL and alias are required.") << endl;
+ ERR << "Too few arguments. At least URL and alias are required." << endl;
+ cout_n << specific_help;
+ return ZYPPER_EXIT_ERR_INVALID_ARGS;
}
Url url = make_url (arguments[0]);
else if (command == ZypperCommand::REMOVE_REPO)
{
- if (ghelp || arguments.size() < 1)
+ if (ghelp)
{
- if (ghelp)
- {
- cout << specific_help;
- return ZYPPER_EXIT_OK;
- }
- else
- {
- cerr << _("Required argument missing.") << endl;
- ERR << "Required argument missing." << endl;
- cout_n << specific_help;
- return ZYPPER_EXIT_ERR_INVALID_ARGS;
- }
+ cout << specific_help;
+ return ZYPPER_EXIT_OK;
+ }
+
+ // check root user
+ if (geteuid() != 0)
+ {
+ cerr << _("Root privileges are required for modifying system repositories.") << endl;
+ return ZYPPER_EXIT_ERR_PRIVILEGES;
+ }
+
+ if (arguments.size() < 1)
+ {
+ cerr << _("Required argument missing.") << endl;
+ ERR << "Required argument missing." << endl;
+ cout_n << specific_help;
+ return ZYPPER_EXIT_ERR_INVALID_ARGS;
}
warn_if_zmd ();
else if (command == ZypperCommand::RENAME_REPO)
{
- if (ghelp || arguments.size() < 2)
+ if (ghelp)
{
- if (ghelp)
- {
- cout << specific_help;
- return ZYPPER_EXIT_OK;
- }
- else
- {
- cerr << _("Too few arguments. At least URL and alias are required.") << endl;
- ERR << "Too few arguments. At least URL and alias are required." << endl;
- cout_n << specific_help;
- return ZYPPER_EXIT_ERR_INVALID_ARGS;
- }
+ cout << specific_help;
+ return ZYPPER_EXIT_OK;
+ }
+
+ // check root user
+ if (geteuid() != 0)
+ {
+ cerr << _("Root privileges are required for modifying system repositories.") << endl;
+ return ZYPPER_EXIT_ERR_PRIVILEGES;
+ }
+
+ if (arguments.size() < 2)
+ {
+ cerr << _("Too few arguments. At least URL and alias are required.") << endl;
+ ERR << "Too few arguments. At least URL and alias are required." << endl;
+ cout_n << specific_help;
+ return ZYPPER_EXIT_ERR_INVALID_ARGS;
}
// cond_init_target ();
else if (command == ZypperCommand::MODIFY_REPO)
{
- if (ghelp || arguments.size() < 1)
+ if (ghelp)
{
- if (ghelp)
- {
- cout << specific_help;
- return ZYPPER_EXIT_OK;
- }
- else
- {
- cerr << _("Alias is a required argument.") << endl;
- ERR << "Na alias argument given." << endl;
- cout_n << specific_help;
- return ZYPPER_EXIT_ERR_INVALID_ARGS;
- }
+ cout << specific_help;
+ return ZYPPER_EXIT_OK;
+ }
+
+ // check root user
+ if (geteuid() != 0)
+ {
+ cerr << _("Root privileges are required for modifying system repositories.") << endl;
+ return ZYPPER_EXIT_ERR_PRIVILEGES;
+ }
+
+ if (arguments.size() < 1)
+ {
+ cerr << _("Alias is a required argument.") << endl;
+ ERR << "Na alias argument given." << endl;
+ cout_n << specific_help;
+ return ZYPPER_EXIT_ERR_INVALID_ARGS;
}
modify_repo(arguments[0], copts);
else if (command == ZypperCommand::REFRESH)
{
- if (ghelp) { cout << specific_help; return !ghelp; }
+ if (ghelp)
+ {
+ cout << specific_help;
+ return ZYPPER_EXIT_OK;
+ }
+
+ // check root user
+ if (geteuid() != 0)
+ {
+ cerr << _("Root privileges are required for refreshing system repositories.") << endl;
+ return ZYPPER_EXIT_ERR_PRIVILEGES;
+ }
refresh_repos();
}
gData.packages_to_uninstall = arguments;
}
+ // check root user
+ if (geteuid() != 0)
+ {
+ cerr << _("Root privileges are required for installing or uninstalling packages.") << endl;
+ return ZYPPER_EXIT_ERR_PRIVILEGES;
+ }
+
// read resolvable type
string skind = copts.count("type")? copts["type"].front() : "package";
kind = string_to_kind (skind);
else if (command == ZypperCommand::UPDATE) {
if (ghelp) { cout << specific_help; return !ghelp; }
+ // check root user
+ if (geteuid() != 0)
+ {
+ cerr << _("Root privileges are required for updating packages.") << endl;
+ return ZYPPER_EXIT_ERR_PRIVILEGES;
+ }
+
string skind = copts.count("type")? copts["type"].front() :
gSettings.is_rug_compatible? "package" : "patch";
kind = string_to_kind (skind);