-u is not required for own username, causes an error if unprivileged.

Bug #1407756 reported by Jim
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-crontab
Fix Released
High
Martin Owens

Bug Description

It is unnecessary to send the -u flag when running as the current user.
Lines 240 and 277 are both sending the -u flag if self.user returns something truthy.
If you change it so that -u is not set when self._user == True it will work as the local user, even if they don't have root privileges for cron.

I tested this on OSX 10.9.5, and RHEL6.

Revision history for this message
Martin Owens (doctormo) wrote :

The lines are 233 and 270 in the most recent release. I can't actually get the error on Ubuntu but I confirmed it on Gentoo and CentOS.

Changed in python-crontab:
assignee: nobody → Martin Owens (doctormo)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Martin Owens (doctormo) wrote :

See release 1.9.1 for the fix.

Changed in python-crontab:
status: Confirmed → Fix Released
Revision history for this message
Jim (jamesprobinsonjr) wrote :

Thank you, I installed 1.9.1 and it fixes the issue I was having. Though looking through the update, I think you may have introduced a bug for anyone who already has root, and wants to read/write from a specific users cron. Specifically, I think when someone uses CronTab(user='another_user') it should still pass the -u flag, and only drop it for CronTab(user=True). I could be wrong though.

Revision history for this message
Martin Owens (doctormo) wrote :

Hi Jim, the best check against that bug is the tests/test_usuage.py which asks for a specific user's crontab and the test script is designed such that it returns that users tab from a specific file. I'm fairly confident it's still working as needed for root but please do check the test suite as I'd always be interested in strengthening it.

Revision history for this message
Jim (jamesprobinsonjr) wrote :

You're right it's working as intended, in my initial look at the patch I missed the significance of "**self.user_opt". Thanks again!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.