private Map<String, String> environment = new HashMap<String, String>();
+ /** Name of the sudo user, root if "", not sudo if null */
+ private String sudo = null;
+
public OsCallBackup() {
}
@Override
public void writeBackup(FileObject targetFo) {
- CommandLine commandLine = CommandLine.parse(command, variables);
+ String commandToUse = command;
+
+ // sudo
+ if (sudo != null) {
+ if (sudo.equals(""))
+ commandToUse = "sudo " + commandToUse;
+ else
+ commandToUse = "sudo -u " + sudo + " " + commandToUse;
+ }
+
+ CommandLine commandLine = CommandLine.parse(commandToUse, variables);
ByteArrayOutputStream errBos = new ByteArrayOutputStream();
if (log.isTraceEnabled())
log.trace(commandLine.toString());
this.executor = executor;
}
+ public void setSudo(String sudo) {
+ this.sudo = sudo;
+ }
+
}