/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2016-03-09 21:23:21 UTC
  • Revision ID: teddy@recompile.se-20160309212321-2qlkzj9tecepc8xq
Server: Add Python 3 compatibility

Add Python 3 compatibility by not using the python-avahi module.  Also
fix miscellaneous things which differs in Python 3.  Especially hard
to fix is loading and saving clients data between Python 3 and 2,
since pickle formats have problems with strings.

* INSTALL: Remove python-avahi (and change python-gobject to
  python-gi, which is preferred now).
* debian/control (Source: mandos/Build-Depends-Indep): Remove
  "python-avahi".
* mandos: Wrap future_builtins import in try-except clause.  Do not
  import avahi module.  Use codecs.decode(..., "base64) instead of
  .decode("base64).  Use .keys(), .values(), and .items() instead of
  .iterkeys(), .itervalues(), and .iteritems().
  (alternate_dbus_interfaces/wrapper): Python 3 still requires the
  "black magic", but luckily it still works.  The Python 3 type()
  constructor requires first argument to be a string, not a byte
  string.
  (copy_function): New.  Use throughout.
  (Avahi, avahi): New class and global variable.
  (GnuTLS._need_version): Changed to be a byte string.
  (main): Decode byte strings loaded from pickle file.
  (main/cleanup): Dump using pickle prototoc 2 which Python 2 can
  read.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1237
1237
           with an explicit route added with the server's address.
1238
1238
           
1239
1239
           Avahi bug reference:
1240
 
           https://lists.freedesktop.org/archives/avahi/2010-February/001833.html
 
1240
           http://lists.freedesktop.org/archives/avahi/2010-February/001833.html
1241
1241
           https://bugs.debian.org/587961
1242
1242
        */
1243
1243
        if(debug){
1423
1423
                                               &decrypted_buffer, mc);
1424
1424
    if(decrypted_buffer_size >= 0){
1425
1425
      
1426
 
      clearerr(stdout);
1427
1426
      written = 0;
1428
1427
      while(written < (size_t) decrypted_buffer_size){
1429
1428
        if(quit_now){
1445
1444
        }
1446
1445
        written += (size_t)ret;
1447
1446
      }
1448
 
      ret = fflush(stdout);
1449
 
      if(ret != 0){
1450
 
        int e = errno;
1451
 
        if(debug){
1452
 
          fprintf_plus(stderr, "Error writing encrypted data: %s\n",
1453
 
                       strerror(errno));
1454
 
        }
1455
 
        errno = e;
1456
 
        goto mandos_end;
1457
 
      }
1458
1447
      retval = 0;
1459
1448
    }
1460
1449
  }
2496
2485
  
2497
2486
  {
2498
2487
    /* Work around Debian bug #633582:
2499
 
       <https://bugs.debian.org/633582> */
 
2488
       <http://bugs.debian.org/633582> */
2500
2489
    
2501
2490
    /* Re-raise privileges */
2502
2491
    ret = raise_privileges();