Skip to content

Commit

Permalink
systemd user/system
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Jul 10, 2020
1 parent e837a2e commit 8538fce
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions schedule/schedule_systemd.go
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/creativeprojects/resticprofile/calendar"
"github.com/creativeprojects/resticprofile/clog"
"github.com/creativeprojects/resticprofile/constants"
"github.com/creativeprojects/resticprofile/systemd"
)
Expand Down Expand Up @@ -37,18 +38,18 @@ func checkSystem() error {
// getSchedulePermission returns the permission defined from the configuration,
// or the best guess considering the current user permission
func (j *Job) getSchedulePermission() string {
// const message = "you have not specified the permission for your schedule (system or user): assuming"
// if j.profile.SchedulePermission == constants.SchedulePermissionSystem ||
// j.profile.SchedulePermission == constants.SchedulePermissionUser {
// // well defined
// return j.profile.SchedulePermission
// }
// // best guess is depending on the user being root or not:
// if os.Geteuid() == 0 {
// clog.Warning(message, "system")
// return constants.SchedulePermissionSystem
// }
// clog.Warning(message, "user")
const message = "you have not specified the permission for your schedule (system or user): assuming"
if j.config.Permission() == constants.SchedulePermissionSystem ||
j.config.Permission() == constants.SchedulePermissionUser {
// well defined
return j.config.Permission()
}
// best guess is depending on the user being root or not:
if os.Geteuid() == 0 {
clog.Warning(message, "system")
return constants.SchedulePermissionSystem
}
clog.Warning(message, "user")
return constants.SchedulePermissionUser
}

Expand Down

0 comments on commit 8538fce

Please sign in to comment.