Fixes for Fedora-15 installation
authorMichal Novotny <minovotn@redhat.com>
Sat, 1 Oct 2011 14:46:46 +0000 (16:46 +0200)
committerMichal Novotny <minovotn@redhat.com>
Sat, 1 Oct 2011 14:46:46 +0000 (16:46 +0200)
Signed-off-by: Michal Novotny <minovotn@redhat.com>

Makefile.am
auth/50-org.libvirt-remote-access.pkla [new file with mode: 0644]
autobuild-official.sh [new file with mode: 0755]
classes/database-file.php
classes/database-mysql.php
classes/database.php
classes/libvirt.php
pages/overview.php
php-virt-control.spec
tools/apache-key-copy.c

index acd839c..eaac218 100644 (file)
@@ -1,3 +1,3 @@
 SUBDIRS = tools
 
-EXTRA_DIST = php-virt-control.spec *.php *.css classes data graphics lang logs pages config
+EXTRA_DIST = php-virt-control.spec *.php *.css classes data graphics lang logs pages config auth
diff --git a/auth/50-org.libvirt-remote-access.pkla b/auth/50-org.libvirt-remote-access.pkla
new file mode 100644 (file)
index 0000000..68e2a25
--- /dev/null
@@ -0,0 +1,6 @@
+[libvirt Management Access]
+Identity=unix-group:apache
+Action=org.libvirt.unix.manage
+ResultAny=yes
+ResultInactive=yes
+ResultActive=yes
diff --git a/autobuild-official.sh b/autobuild-official.sh
new file mode 100755 (executable)
index 0000000..7d709e1
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+set -e
+set -v
+
+make distclean || :
+
+aclocal
+autoreconf -i -f
+
+./configure --prefix=$AUTOBUILD_INSTALL_ROOT
+
+#make
+#make install
+
+rm -f *.tar.gz
+make dist
+
+if [ -x /usr/bin/rpmbuild ]
+then
+  rpmbuild --nodeps \
+     --define "_sourcedir `pwd`" \
+     -ba --clean php-virt-control.spec
+fi
index c690466..854e66f 100644 (file)
                        return true;
                }
 
+               function init() {
+                       return true;
+               }
+
                /* Parse function */
                function parse_data() {
                        $id = 0;
index 186822c..3273ae6 100644 (file)
                        return true;
                }
 
+               function init() {
+                       $res = mysql_query('SELECT * FROM '.$this->prefix.$this->tab_connections);
+                       if ($res)
+                               return true;
+
+                       $qry = 'CREATE TABLE IF NOT EXISTS '.$this->prefix.$this->tab_connections.' ('.
+                                       'id int(11) NOT NULL AUTO_INCREMENT,'.
+                                       'name varchar(255) NOT NULL,'.
+                                       'hv varchar(5) NOT NULL,'.
+                                       'type tinyint(4) NOT NULL,.'
+                                       'method varchar(3) NOT NULL,'.
+                                       'require_pwd tinyint(4) NOT NULL,'.
+                                       'user varchar(255) NOT NULL,'.
+                                       'host varchar(255) NOT NULL,'.
+                                       'logfile varchar(255) NOT NULL,'.
+                                       'PRIMARY KEY (id)'.
+                               ') ENGINE=MyISAM  DEFAULT CHARSET=utf8';
+
+                       return is_resource( mysql_query($qry) );
+               }
+
                function refresh() {
                        $res = mysql_query('SELECT * FROM '.$this->prefix.$this->tab_connections);
                        if (!$res)
index e1b7b83..7abb25b 100644 (file)
                        return false;
                }
 
+               function init() {
+                       return $this->err('init', $this->unimpl);
+               }
+
                function has_fatal_error() {
                        return $this->fatal;
                }
index d3e9b97..f9f993e 100644 (file)
                        $ok = is_resource($test);
                        unset($test);
 
+                       if (!$ok)
+                               $this->_set_last_error();
+
                        return $ok;
                }
 
index 7e5d1e1..905fec0 100644 (file)
                        $skip_rest = true;
                }
                else {
-                       echo '<p>'.$lang->get('conn_failed').': '.$uri.'</p>';
+                       echo '<p>'.$lang->get('conn_failed').': '.$uri.' '.($lv->get_last_error() ? '('.$lv->get_last_error().')' : '').'</p>';
                }
        }
 
index eb748e8..32062aa 100644 (file)
@@ -1,6 +1,6 @@
 Name:          php-virt-control
 Version:       0.0.2
-Release:       2%{?dist}%{?extra_release}
+Release:       3%{?dist}%{?extra_release}
 Summary:       PHP-based virtual machine control tool
 Group:         Applications/Internet
 License:       GPLv3
@@ -60,6 +60,7 @@ cp -af *.css %{buildroot}%{_datadir}/%{name}/
 cp -af classes/ data/ graphics/ lang/ logs/ pages/ %{buildroot}%{_datadir}/%{name}/
 cp -af config/connection.php %{buildroot}/%{_sysconfdir}/%{name}/connection.php
 cp -af config/mysql-connection.php %{buildroot}/%{_sysconfdir}/%{name}/mysql-connection.php
+install -Dp -m0644 auth/50-org.libvirt-remote-access.pkla %{buildroot}/etc/polkit-1/localauthority/50-local.d/50-org.libvirt-remote-access.pkla
 install -Dp -m0644 php-virt-control.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/php-virt-control.conf
 
 %clean
@@ -71,10 +72,14 @@ rm -rf %{buildroot}
 %config(noreplace) %{_sysconfdir}/%{name}/connection.php
 %config(noreplace) %{_sysconfdir}/%{name}/mysql-connection.php
 %config(noreplace) %{_sysconfdir}/httpd/conf.d/php-virt-control.conf
+%config(noreplace) /etc/polkit-1/localauthority/50-local.d/50-org.libvirt-remote-access.pkla
 %{_bindir}/apache-key-copy
 %{_datadir}/%{name}/
 
 %changelog
+* Sat Oct 01 2011 Michal Novotny <minovotn@redhat.com> - 0.0.2-3
+- Fixes for Fedora-15 and policy kit
+
 * Tue Aug 30 2011 Michal Novotny <minovotn@redhat.com> - 0.0.2-2
 - Fix for SPEC file and installation
 
index f690a5e..749b4ca 100644 (file)
@@ -18,7 +18,7 @@ char *get_user_home_dir(char *user)
        return pwd->pw_dir;
 }
 
-int get_user_uid(char *user)
+int get_user_uid(char *user, int *oGid)
 {
        struct passwd *pwd;
 
@@ -26,6 +26,9 @@ int get_user_uid(char *user)
        if (!pwd)
                return -1;
 
+       if (oGid != NULL)
+               *oGid = pwd->pw_gid;
+
        return pwd->pw_uid;
 }
 
@@ -68,7 +71,7 @@ void copy_key(char *keyfile, char *host)
 
 int main(int argc, char *argv[])
 {
-       int uid, olduid;
+       int uid, olduid, gid;
        char *dir = NULL;
        char *user = APACHE_USER;
        char keyfile[1024] = { 0 };
@@ -94,11 +97,16 @@ int main(int argc, char *argv[])
                return 3;
        }
 
-       uid = get_user_uid(user);
+       uid = get_user_uid(user, &gid);
        if (uid < 0) {
                fprintf(stderr, "Error: Cannot get uid for user %d\n", user);
                return 4;
        }
+
+       snprintf(keyfile, sizeof(keyfile), "%s/.ssh", dir);
+       mkdir(keyfile, 0700);
+       chown(keyfile, uid, gid);
+
        olduid = getuid();
        setuid(uid);