Skip to content

Commit

Permalink
Only restrict root user from using the interactive interfaces (socket…
Browse files Browse the repository at this point in the history
…s/CORBA)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23192 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 4, 2014
1 parent dc16af3 commit 7175696
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Compiler/Main/Main.mo
Expand Up @@ -844,13 +844,10 @@ algorithm
end if;

// Don't allow running omc as root due to security risks.
if System.userIsRoot() then
print(System.gettext("You are trying to run OpenModelica as root.\n"));
print("This is a very bad idea. Why you ask?\n");
print("* The socket interface does not authenticate the user.\n");
print("* OpenModelica allows execution of arbitrary commands.\n");
print("The good news is there is no reason to run OpenModelica as root.\n");
return;
if System.userIsRoot() and (Flags.isSet(Flags.INTERACTIVE) or Flags.isSet(Flags.INTERACTIVE_CORBA)) then
Error.addMessage(Error.ROOT_USER_INTERACTIVE, {});
print(ErrorExt.printMessagesStr(false));
fail();
end if;

// Setup mingw path only once
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Util/Error.mo
Expand Up @@ -774,6 +774,8 @@ public constant Message CLASS_NOT_FOUND = MESSAGE(555, SCRIPTING(), WARNING(),
Util.gettext("Class %s not found inside class %s."));
public constant Message NOTIFY_LOAD_MODEL_FAILED = MESSAGE(556, SCRIPTING(), NOTIFICATION(),
Util.gettext("Skipped loading package %s (%s) using MODELICAPATH %s (uses-annotation may be wrong)."));
public constant Message ROOT_USER_INTERACTIVE = MESSAGE(557, SCRIPTING(), ERROR(),
Util.gettext("You are trying to run OpenModelica as a server using the root user.\nThis is a very bad idea:\n* The socket interface does not authenticate the user.\n* OpenModelica allows execution of arbitrary commands."));

public constant Message MATCH_SHADOWING = MESSAGE(5001, TRANSLATION(), ERROR(),
Util.gettext("Local variable '%s' shadows another variable."));
Expand Down

0 comments on commit 7175696

Please sign in to comment.