Bug 1540382 - sudo requires a tty while running katello-backup from cron [NEEDINFO]
Summary: sudo requires a tty while running katello-backup from cron
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Backup & Restore
Version: 6.2.13
Hardware: Unspecified
OS: Unspecified
high vote
Target Milestone: Unspecified
Assignee: Evgeni Golov
QA Contact: Kedar Bidarkar
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
Reported: 2018-01-31 00:09 UTC by Alexey Masolov
Modified: 2021-09-09 13:07 UTC (History)
17 users (show)

Fixed In Version: katello-3.4.5-19
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1596353 (view as bug list)
Last Closed: 2018-08-22 20:07:08 UTC
Target Upstream Version:
peli: needinfo? (chsimon)

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 22551 0 Normal Closed sudo requires a tty while running katello-backup from cron 2021-02-09 16:16:33 UTC
Red Hat Knowledge Base (Solution) 3346741 0 None None None 2018-02-07 12:00:06 UTC
Red Hat Knowledge Base (Solution) 3354581 0 None None None 2018-02-15 13:35:38 UTC

Description Alexey Masolov 2018-01-31 00:09:42 UTC
Description of problem:
If you run katello-backup from cron then it fails with

'sorry, you must have a tty to run sudo'

Version-Release number of selected component (if applicable):
Satellite 6.2.13

How reproducible:

Steps to Reproduce:

Put this line to crontab

33 15 * * * root /usr/bin/katello-backup /var/sat-content --online-backup --skip-pulp-content >> /var/log/satellite/backups.log 2>&1

Actual results:
Starting backup: 2018-01-27 15:33:02 +1100
Creating backup folder /var/sat-content/katello-backup-20180127153302
sudo: sorry, you must have a tty to run sudo

Expected results:
Completed backup

Comment 1 Alexey Masolov 2018-01-31 00:10:52 UTC
I also found that adding this line to /etc/sudoers help to avoid the error but this workaround is unacceptable in secured environments. 

Default !requiretty

Comment 4 Evgeni Golov 2018-02-12 12:41:03 UTC
Created redmine issue http://projects.theforeman.org/issues/22551 from this bug

Comment 5 Satellite Program 2018-02-12 13:06:27 UTC
Upstream bug assigned to egolov@redhat.com

Comment 8 David Leatherman 2018-03-29 12:34:59 UTC
Reproduced it and the fix  "Default !requiretty" in the /etc/sudoers violates our security protocols.

Comment 15 Kedar Bidarkar 2018-08-01 13:06:01 UTC
Added the below entry to /etc/crontab file on the Satellite6

00 09 * * *  root /usr/sbin/satellite-backup -y /var/tmp/sat-content --online-backup --skip-pulp-content >> /var/log/satellite/backups.log 2>&1


Starting backup: 2018-08-01 09:00:02 -0400
Creating backup folder /var/tmp/sat-content/satellite-backup-20180801090002
Generating metadata ... 
Backing up config files... 
Backing up postgres online schema... 
Backing up mongo online schema... 
Done with backup: 2018-08-01 09:01:24 -0400
**** BACKUP Complete, contents can be found in: /var/tmp/sat-content/satellite-backup-20180801090002 ****

[root@testing-sat6 satellite-backup-20180801090002]# ls
candlepin.dump  config_files.tar.gz  foreman.dump  metadata.yml  mongo_dump  pg_globals.dump

VERIFIED with sat6.3.3 snap2 build

Comment 17 errata-xmlrpc 2018-08-22 20:07:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.