Author: jreidinger Date: Thu Jul 3 15:34:49 2008 New Revision: 48835 URL: http://svn.opensuse.org/viewcvs/yast?rev=48835&view=rev Log: add binding for grant authentification Modified: branches/tmp/lslezak/workshop/auth_dbus_layer/Makefile branches/tmp/lslezak/workshop/auth_dbus_layer/dbus-svc-info branches/tmp/lslezak/workshop/auth_dbus_layer/polkit.c branches/tmp/lslezak/workshop/auth_dbus_layer/polkitwrapper.py Modified: branches/tmp/lslezak/workshop/auth_dbus_layer/Makefile URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/auth_dbus... ============================================================================== --- branches/tmp/lslezak/workshop/auth_dbus_layer/Makefile (original) +++ branches/tmp/lslezak/workshop/auth_dbus_layer/Makefile Thu Jul 3 15:34:49 2008 @@ -1,6 +1,6 @@ LIB:=$(shell y2tool get-lib) polkitbind.so: polkit.c - gcc -fPIC -rdynamic -L/$(LIB) -lpython2.5 -ldbus-1 -lpolkit -lpolkit-dbus -I/usr/include/python -I/usr/include/PolicyKit -I/usr/include/dbus-1.0 -I/usr/$(LIB)/dbus-1.0/include -shared -o polkitbind.so polkit.c + gcc -fPIC -rdynamic -Wall -Wextra -L/$(LIB) -lpython2.5 -ldbus-1 -lpolkit -lpolkit-dbus -I/usr/include/python -I/usr/include/PolicyKit -I/usr/include/dbus-1.0 -I/usr/$(LIB)/dbus-1.0/include -shared -o polkitbind.so polkit.c PYFILES=AuthException.py auth_layer_service.py polkitbind.so polkitwrapper.py install: Modified: branches/tmp/lslezak/workshop/auth_dbus_layer/dbus-svc-info URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/auth_dbus... ============================================================================== --- branches/tmp/lslezak/workshop/auth_dbus_layer/dbus-svc-info (original) +++ branches/tmp/lslezak/workshop/auth_dbus_layer/dbus-svc-info Thu Jul 3 15:34:49 2008 @@ -37,3 +37,5 @@ dump_name("org.freedesktop.Avahi") +dump_name("org.opensuse.YaST.Auth") + Modified: branches/tmp/lslezak/workshop/auth_dbus_layer/polkit.c URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/auth_dbus... ============================================================================== --- branches/tmp/lslezak/workshop/auth_dbus_layer/polkit.c (original) +++ branches/tmp/lslezak/workshop/auth_dbus_layer/polkit.c Thu Jul 3 15:34:49 2008 @@ -23,7 +23,6 @@ PolKitAction *action = NULL; PolKitContext *context = NULL; PolKitError *polkit_error = NULL; - PolKitSession *session = NULL; PolKitResult polkit_result; dbus_error_init(&dbus_error); @@ -125,8 +124,37 @@ return pResult; } +PyObject* authWrap(PyObject* self, PyObject* args) +{ + PyObject* pResult; + int result; + char* arg_action; + DBusError error; + + dbus_error_init(&error); + + PyArg_ParseTuple(args, "s", &arg_action); + + FILE* log = fopen("/tmp/polkitcheck.log","a") + fprintf(log,"try authorize action %s for user %u \n", arg_action, getuid()); + result = polkit_auth_obtain( arg_action, 0, getpid(), &error ); + pResult = Py_BuildValue("i", result); + + if (dbus_error_is_set(&error)){ + fprintf(log,"error: %s \n message: %s \n",error.name, error.message); + } + + dbus_error_free(&error); + + fprintf(out, "result is %i\n", result); + + return pResult; +} + + static PyMethodDef methods[] = { - {"checkPolicyLow", checkWrap, METH_VARARGS, "policy kit wrapper"}, + {"checkPolicyLow", checkWrap, METH_VARARGS, "check policy kit rules"}, + {"authUserLow", authWrap, METH_VARARGS, "authorize user"}, {NULL, NULL, 0, NULL} }; Modified: branches/tmp/lslezak/workshop/auth_dbus_layer/polkitwrapper.py URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/auth_dbus... ============================================================================== --- branches/tmp/lslezak/workshop/auth_dbus_layer/polkitwrapper.py (original) +++ branches/tmp/lslezak/workshop/auth_dbus_layer/polkitwrapper.py Thu Jul 3 15:34:49 2008 @@ -19,7 +19,9 @@ def __doc__(): return "throw exception when authorization required or permision denied see AuthException module. Return 0." - + +def AuthUser(action, servicename): + return polkitbind.authUserLow( action ) if __name__=="__main__": - print PolkitCheck("org.yast.policy",':1.8') + print AuthUser("org.opensuse.yast.sysconfig.kdump.dir",'org.opensuse.YaST.Auth') -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org