libselinux: make python bindings for restorecon work on relative path

This patch just makes python bindings for restorecon work on relative
paths.

$ cd /etc
$ python
> import selinux
> selinux.restorecon("resolv.conf")

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
index faf7ac5..daf8314 100644
--- a/libselinux/src/selinuxswig_python.i
+++ b/libselinux/src/selinuxswig_python.i
@@ -12,8 +12,15 @@
 
 def restorecon(path, recursive=False):
     """ Restore SELinux context on a given path """
-    mode = os.lstat(path)[stat.ST_MODE]
-    status, context = matchpathcon(path, mode)
+
+    try:
+        mode = os.lstat(path)[stat.ST_MODE]
+        status, context = matchpathcon(path, mode)
+    except OSError:
+        path = os.path.realpath(os.path.expanduser(path))
+        mode = os.lstat(path)[stat.ST_MODE]
+        status, context = matchpathcon(path, mode)
+
     if status == 0:
         lsetfilecon(path, context)
         if recursive: