[Kimchi-devel] [PATCH] Issue #320: give friendly prompt when kimchid fails to run with non-root user

Sheldon shaohef at linux.vnet.ibm.com
Fri Feb 21 22:13:37 UTC 2014


On 02/22/2014 02:52 AM, Ramon Medeiros wrote:
> Aline sent a patch to correct this, also, this kind of fix is very 
> superficial.
>
> If the user delete the log? I guess it would pass since the user is 
> non-root
we can check the error number just focus on EACCES.
+ if e.errno == errno.EACCES:
+ print "Please run kimchi with root user"
+ print "If you want to run kimchi with non-root user, ",
+ print "you can change the permission of %s" % e.filename

just delete the log file, if the log path is still non-permission, it 
still will cause EACCES.

delete the no-permission path and file, python log will create the log, 
kimchi can run well without IOError.

there will be never ENOENT if the user delete the log.

>
>
> On 02/21/2014 05:45 AM, shaohef at linux.vnet.ibm.com wrote:
>> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>>
>> If a non-root/non-sudo user tries to run kimchid, it fails with the
>> verbose stacktrace.
>>
>> This is not friendly to user.
>>
>> There should be a check for these cases, allowing kimchid to fail
>> gracefully.
>>
>> Issue:
>> https://github.com/kimchi-project/kimchi/issues/320
>>
>> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>> ---
>> src/kimchi/server.py | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/kimchi/server.py b/src/kimchi/server.py
>> index 6dd0404..f93b6ee 100644
>> --- a/src/kimchi/server.py
>> +++ b/src/kimchi/server.py
>> @@ -158,8 +158,13 @@ class Server(object):
>> pass
>>
>> cherrypy.log.screen = True
>> - cherrypy.log.access_file = options.access_log
>> - cherrypy.log.error_file = options.error_log
>> + try:
>> + cherrypy.log.access_file = options.access_log
>> + cherrypy.log.error_file = options.error_log
>> + except IOError as e:
>> + print e
>> + print "Please run kimchi with root user"
>> + exit()
>>
>> logLevel = LOGGING_LEVEL.get(options.log_level, logging.DEBUG)
>> dev_env = options.environment != 'production'
>
>


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list