Добавлен скрипт-wrapper для запуска методов от пользовтеля и root

master-3.5 3.5.0_alpha12
parent fb0bba1509
commit a02f8ac60c

@ -15,40 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import calculate.core.core_main as core_main
if hasattr(sys, "setdefaultencoding"):
sys.setdefaultencoding("utf-8")
from calculate.lib.cl_lang import setLocalTranslate
_ = lambda x: x
setLocalTranslate('cl_core', sys.modules[__name__])
from traceback import print_exc
try:
from calculate.core.server.cl_server import main
reload(sys)
from calculate.lib.datavars import CriticalError, DataVarsError
if __name__ == '__main__':
try:
sys.exit(main())
except (CriticalError, DataVarsError) as e:
sys.stderr.write("%s\n" % str(e))
sys.exit(1)
except ImportError as e:
print_exc()
cannot_import = 'cannot import name '
no_module = 'No module named '
if e.message.startswith(cannot_import):
print (_('Failed to import %s')
% e.message.rpartition(cannot_import)[2])
elif e.message.startswith(no_module):
print (_('No module named %s') %
e.message.rpartition(no_module)[2])
else:
print e.message
except KeyboardInterrupt:
print
print _("Task interrupted")
if __name__ == '__main__':
core_main.core_main()

@ -0,0 +1,31 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import calculate.core.core_main as core_main
if __name__ == '__main__':
if os.getuid() != 0:
try:
import calculate.console.console_main as console_main
console_main.console_main()
except ImportError as e:
print str(e)
pass
else:
core_main.core_main()

@ -0,0 +1,55 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def core_main():
import sys
if hasattr(sys, "setdefaultencoding"):
sys.setdefaultencoding("utf-8")
from calculate.lib.cl_lang import setLocalTranslate
_ = lambda x: x
setLocalTranslate('cl_core', sys.modules[__name__])
from traceback import print_exc
try:
from calculate.core.server.cl_server import main
reload(sys)
from calculate.lib.datavars import CriticalError, DataVarsError
try:
sys.exit(main())
except (CriticalError, DataVarsError) as e:
sys.stderr.write("%s\n" % str(e))
sys.exit(1)
except ImportError as e:
print_exc()
cannot_import = 'cannot import name '
no_module = 'No module named '
if e.message.startswith(cannot_import):
print (_('Failed to import %s')
% e.message.rpartition(cannot_import)[2])
elif e.message.startswith(no_module):
print (_('No module named %s') %
e.message.rpartition(no_module)[2])
else:
print e.message
except KeyboardInterrupt:
print
print _("Task interrupted")

@ -1456,8 +1456,9 @@ class CoreWsdl(CoreServiceInterface):
def create_symlink(data_path, old_data_path):
meths = LoadedMethods.conMethods
path_to_link = '/usr/sbin'
path_to_user_link = '/usr/bin'
path_to_link = '/usr/bin'
core_wrapper = "/usr/libexec/calculate/cl-core-wrapper"
#path_to_user_link = '/usr/bin'
old_symlinks_file = os.path.join(old_data_path, 'conf/symlinks')
symlinks_file = os.path.join(data_path, 'conf/symlinks')
if not os.path.exists(os.path.join(data_path, 'conf')):
@ -1471,10 +1472,7 @@ def create_symlink(data_path, old_data_path):
os.unlink(old_symlinks_file)
fd = open(symlinks_file, 'a')
for link in meths:
if meths[link][1]:
link_path = os.path.join(path_to_user_link, link)
else:
link_path = os.path.join(path_to_link, link)
link_path = os.path.join(path_to_link, link)
if os.path.islink(link_path):
continue
if os.path.isfile(link_path):
@ -1482,7 +1480,11 @@ def create_symlink(data_path, old_data_path):
print red + link_path + _(' is a file, not a link!')
continue
try:
os.symlink(os.path.join(path_to_link, 'cl-core'), link_path)
if (os.path.islink(link_path) and
os.readlink(link_path) != core_wrapper):
os.unlink(link_path)
print "REFRESH OLD", link_path
os.symlink(core_wrapper, link_path)
fd.write(link_path + '\n')
except OSError, e:
print e.message
@ -1494,10 +1496,7 @@ def create_symlink(data_path, old_data_path):
temp_text_file = ''
for line in readLinesFile(symlinks_file):
cmdname = os.path.basename(line)
if (cmdname not in meths.keys() or
line.startswith(path_to_link) and meths[cmdname][1] or
line.startswith(path_to_user_link) and
not meths[cmdname][1]):
if cmdname not in meths.keys() or not line.startswith(path_to_link):
if os.path.islink(line):
os.unlink(line)
print _('Symlink %s deleted') % line

@ -89,6 +89,7 @@ setup(
('/etc/init.d', [('data/calculate-core',0755)]),
('/usr/share/man/man1',glob('man/cl-*')),
('/usr/share/man/ru/man1',glob('man/ru/*')),
('/usr/libexec/calculate', [('data/cl-core-wrapper', 0755)]),
('/usr/libexec/calculate', [('data/cl-pkg-cache', 0755)]),
('/usr/libexec/calculate', [('data/cl-variable', 0755)])
),

Loading…
Cancel
Save