Blog Pseudoaccidentale

2009-07-05

fts(3) or Avoiding to Reinvent the Wheel

One of the C programs I was working on this weekend had to find all files that satisfy a certain predicate and add them to a list of “pending work”. The first thing that comes to mind is probably a custom opendir(), readdir(), closedir() hack. This is probably ok when one only has these structures, but it also a bit cumbersome. There are various sorts of DIR and dirent structures and recursing down a large path requires manually keeping track of a lot of state.

A small program that uses opendir() and its friends to traverse a hierarchy of files and print their names may look like this:

% cat -n opendir-sample.c
     1  #include <sys/types.h>
     2
     3  #include <sys/stat.h>
     4
     5  #include <assert.h>
     6  #include <dirent.h>
     7  #include <limits.h>
     8  #include <stdio.h>
     9  #include <string.h>
    10
    11  static int      ptree(char *curpath, char * const path);
    12
    13  int
    14  main(int argc, char * const argv[])
    15  {
    16          int k;
    17          int rval;
    18
    19          for (rval = 0, k = 1; k < argc; k++)
    20                  if (ptree(NULL, argv[k]) != 0)
    21                          rval = 1;
    22          return rval;
    23  }
    24
    25  static int
    26  ptree(char *curpath, char * const path)
    27  {
    28          char ep[PATH_MAX];
    29          char p[PATH_MAX];
    30          DIR *dirp;
    31          struct dirent entry;
    32          struct dirent *endp;
    33          struct stat st;
    34
    35          if (curpath != NULL)
    36                  snprintf(ep, sizeof(ep), "%s/%s", curpath, path);
    37          else
    38                  snprintf(ep, sizeof(ep), "%s", path);
    39          if (stat(ep, &st) == -1)
    40                  return -1;
    41          if ((dirp = opendir(ep)) == NULL)
    42                  return -1;
    43          for (;;) {
    44                  endp = NULL;
    45                  if (readdir_r(dirp, &entry, &endp) == -1) {
    46                          closedir(dirp);
    47                          return -1;
    48                  }
    49                  if (endp == NULL)
    50                          break;
    51                  assert(endp == &entry);
    52                  if (strcmp(entry.d_name, ".") == 0 ||
    53                      strcmp(entry.d_name, "..") == 0)
    54                          continue;
    55                  if (curpath != NULL)
    56                          snprintf(ep, sizeof(ep), "%s/%s/%s", curpath,
    57                              path, entry.d_name);
    58                  else
    59                          snprintf(ep, sizeof(ep), "%s/%s", path,
    60                              entry.d_name);
    61                  if (stat(ep, &st) == -1) {
    62                          closedir(dirp);
    63                          return -1;
    64                  }
    65                  if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) {
    66                          printf("%c %s\n", S_ISDIR(st.st_mode) ? 'd' : 'f', ep);
    67                  }
    68                  if (S_ISDIR(st.st_mode) == 0)
    69                          continue;
    70                  if (curpath != NULL)
    71                          snprintf(p, sizeof(p), "%s/%s", curpath, path);
    72                  else
    73                          snprintf(p, sizeof(p), "%s", path);
    74                  snprintf(ep, sizeof(ep), "%s", entry.d_name);
    75                  ptree(p, ep);
    76          }
    77          closedir(dirp);
    78          return 0;
    79  }

With more than 80 lines, this looks a bit too complex for the simple task it does. It has to keep a lot of temporary state information around in the two ep[] and p[] buffers, and all the manual work of setting updating and maintaining this internal state is adding so much noise around the actual printf() statement at line 68 that it is almost too hard to understand what this particular bit of code is supposed to do.

The program still “works”, in a way, so if you compile and run it, the expected results come up:

keramida@kobe:/home/keramida$ cc -O2 opendir-sample.c
keramida@kobe:/home/keramida$ ./a.out /tmp
d /tmp/.snap
d /tmp/.X11-unix
d /tmp/.XIM-unix
d /tmp/.ICE-unix
d /tmp/.font-unix
f /tmp/aprtdTjbX
f /tmp/aprEdWP4d
d /tmp/fam-gdm
f /tmp/.X0-lock
d /tmp/fam-keramida
d /tmp/.esd-1000
d /tmp/screens
d /tmp/screens/S-root
d /tmp/screens/S-keramida
d /tmp/emacs1000
f /tmp/a
f /tmp/b
f /tmp/kot
f /tmp/logsort
keramida@kobe:/home/keramida$ ./a.out /tmp /etc/defaults
d /tmp/.snap
d /tmp/.X11-unix
d /tmp/.XIM-unix
d /tmp/.ICE-unix
d /tmp/.font-unix
f /tmp/aprtdTjbX
f /tmp/aprEdWP4d
d /tmp/fam-gdm
f /tmp/.X0-lock
d /tmp/fam-keramida
d /tmp/.esd-1000
d /tmp/screens
d /tmp/screens/S-root
d /tmp/screens/S-keramida
d /tmp/emacs1000
f /tmp/a
f /tmp/b
f /tmp/kot
f /tmp/logsort
f /etc/defaults/rc.conf
f /etc/defaults/bluetooth.device.conf
f /etc/defaults/devfs.rules
f /etc/defaults/periodic.conf

But this program looks “ugly”. Fortunately, the BSDs and Linux provide a more elegant interface for traversing file hierarchies: the fts(3) family of functions. A similar program that uses fts(3) to traverse the filesystem hierarchies rooted at the arguments of main() is:

% cat -n fts-sample.c
     1  #include <sys/types.h>
     2
     3  #include <sys/stat.h>
     4
     5  #include <err.h>
     6  #include <fts.h>
     7  #include <stdio.h>
     8
     9  static int      ptree(char * const argv[]);
    10
    11  int
    12  main(int argc, char * const argv[])
    13  {
    14          int rc;
    15
    16          if ((rc = ptree(argv + 1)) != 0)
    17                  rc = 1;
    18          return rc;
    19  }
    20
    21  static int
    22  ptree(char * const argv[])
    23  {
    24          FTS *ftsp;
    25          FTSENT *p, *chp;
    26          int fts_options = FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR;
    27          int rval = 0;
    28
    29          if ((ftsp = fts_open(argv, fts_options, NULL)) == NULL) {
    30                  warn("fts_open");
    31                  return -1;
    32          }
    33          /* Initialize ftsp with as many argv[] parts as possible. */
    34          chp = fts_children(ftsp, 0);
    35          if (chp == NULL) {
    36                  return 0;               /* no files to traverse */
    37          }
    38          while ((p = fts_read(ftsp)) != NULL) {
    39                  switch (p->fts_info) {
    40                  case FTS_D:
    41                          printf("d %s\n", p->fts_path);
    42                          break;
    43                  case FTS_F:
    44                          printf("f %s\n", p->fts_path);
    45                          break;
    46                  default:
    47                          break;
    48                  }
    49          }
    50          fts_close(ftsp);
    51          return 0;
    52  }

This version is not particularly smaller; it’s only 34-35% smaller in LOC. It is, however, far more elegant and a lot easier to read:

  • By using a higher level interface, the program is shorter and easier to understand.
  • By using simpler constructs in the fts_read() loop, it very obvious what the program does for each file type (file vs. directory).
  • The FTS_COMFOLLOW flag sets up things for following symbolic links in one simple place (something entirely missing from the opendir version).
  • There are no obvious bugs about copying half of a pathname, or forgetting to recurse in some cases, or forgetting to print some directory because of a complex interaction between superfluous bits of code. Simpler is also less prone to bugs in this case.

So the next time you are about to build a filesystem traversal toolset from scratch, you can avoid all the pain (and bugs): use fts(3)! :-)

2009-07-01

Ιδιωτικότητα και Ελευθερία του Λόγου στο Διαδίκτυο

Filed under: Computers, Network Freedom, Software — keramida @ 12:22:19

Σήμερα εμφανίστηκαν σε διάφορα Ελληνικά weblogs άρθρα που αγγίζουν το θέμα της “ελευθερίας του λόγου στο διαδίκτυο”.

Ενδιαφέρουσα είναι η άποψη του http://metablogging.gr/archives/2432. Πολύ ενδιαφέρουσα είναι επίσης κι η γνωμοδότηση του κ. Σανιδά, όπως καταγράφεται στα άρθρα της Καθημερινής, του Βήματος και της Ελευθεροτυπίας.

Το κείμενο στο «Βήμα» μοιάζει να έχει γραφτεί λίγο βιαστικά. Με κορώνες όπως «Αίρεται το απόρρητο επιστολών για τους bloggers» δείχνει να έχει γραφτεί στο πόδι, με σκοπό κυρίως τον ενυπωσιασμό των αναγνωστών. Προφανώς το απόρρητο δεν «αίρεται» με μια γνωμοδότηση, αφού δεν είναι δημοσιευμένος νόμος του Κράτους. Ούτε γράφουν «επιστολές» οι bloggers, άρθρα γράφουν! Καμιά φορά αναφέρονται και σε μέρη από επιστολές, αλλά αυτό γίνεται με τον ίδιο τρόπο που μια εφημερίδα αναφέρει αποσπάσματα από κάποιο άλλο γραπτό κείμενο. Το ίδιο το κείμενο της γνωμοδότησης δεν υπάρχει στο «Βήμα». Αναφέρονται μόνο πολύ λίγα και πολύ μικρά μέρη του. Ο βασικός κορμός του άρθρου είναι μια ερμηνεία του «Βήματος», με την οποία δε θα ασχοληθώ καν. Δεν αξίζει τον κόπο.

Το άρθρο της «Καθημερινής», αντίθετα, είναι πολύ καλογραμμένο. Αν το κείμενο το οποίο αναφέρει ως μέρος της γνωμοδότησης είναι πιστό αντίγραφο από το κείμενο του κ. Σανιδά, αξίζει να το διαβάσουμε με πολλή προσοχή.

Ειδικότερα. Στην γνωμοδότήση του ο Σανιδάς καταλήγει:

«1) Το απόρρητο των επικοινωνιών δεν καλύπτει α) την επικοινωνία μέσω του διαδικτύου (Internet) και β) τα εξωτερικά στοιχεία της επικοινωνίας (ονοματεπώνυμα και λοιπά στοιχεία συνδρομητών, αριθμοί τηλεφώνων, χρόνος και τόπος κλήσεως, διάρκεια συνδιάλεξης κ.λ.π.)

1) Οι εισαγγελικές, ανακριτικές και προανακριτικές αρχές, πολύ δε περισσότερο τα Δικαστικά Συμβούλια και τα Δικαστήρια, δικαιούνται να ζητούν από τους παρόχους των υπηρεσιών Επικοινωνίας, μέσω του διαδικτύου (Internet) τα ηλεκτρονικά ίχνη μιας εγκληματικής πράξεως, την ημεροχρονολογία και τα στοιχεία του προσώπου στο οποίο αντιστοιχεί το ηλεκτρονικό ίχνος, από τους λοιπούς δε παρόχους των υπηρεσιών επικοινωνίας τα ‘εξωτερικά στοιχεία’ της επικοινωνίας και ο πάροχος υποχρεούται να τα παραδίδει χωρίς να είναι αναγκαίο να προηγηθεί άδεια κάποιας Αρχής και ιδία της Αρχής Διασφάλισης του Απορρήτου των Επικοινωνιών.

2) Η Αρχή Διασφάλισης του Απορρήτου των Επικοινωνιών αλλά και οποιαδήποτε άλλη Ανεξάρτητη Αρχή ούτε νομιμοποιείται ούτε δικαιούται να ελέγξει με οποιονδήποτε τρόπο, αμέσως ή εμμέσως, το εάν η περί άρσεως ή μη του απορρήτου απόφαση των οργάνων της Δικαιοσύνης είναι σύννομη ή όχι. Αυτό κρίνεται από τα ίδια τα όργανα της Δικαιοσύνης. Ούτε όμως περαιτέρω η ρηθείσα Αρχή μπορεί να ελέγξει τους παρόχους υπηρεσιών επικοινωνίας για τη, σε κάθε περίπτωση, συμμόρφωσή τους προς τις αποφάσεις των οργάνων της Δικαιοσύνης. Εάν πράξει τούτο ενεργεί καθ’ υπέρβαση της δικαιοδοσίας της».

— «ΚΑΘΗΜΕΡΙΝΗ», 29 Ιουνίου 2009 http://www.kathimerini.gr/4dcgi/_w_articles_kathremote_1_29/06/2009_286481

Δεν ξέρω πόσο μπορεί μια γνωμοδότηση σαν αυτή να επηρεάσει τη λειτουργία της Δικαιοσύνης, αλλά ακόμη και ελάχιστη επιρροή να έχει, αξίζει να προσέξουμε πολύ μια συγκεκριμένη έκφραση:

Το απόρρητο των επικοινωνιών δεν καλύπτει α) την επικοινωνία μέσω του διαδικτύου (Internet)

Δεν είμαι σίγουρος ότι ο κ. Σανιδάς εννοεί ακριβώς αυτό που κυριολεκτικά γράφεται παραπάνω, αλλά αν όντως θεωρεί ότι κάθε επικοινωνία μέσω Διαδικτύου εκπίπτει του απορρήτου των επικοινωνιών, τότε ελπίζω να μην κωδικοποιηθεί σε κάποιο νόμο αυτό. Αν γίνει κάτι τέτοιο τότε είναι φοβερά απίθανο να μην μπει στον πειρασμό ο νομοθέτης να αχρηστεύσει εντελώς κάθε επικοινωνία στο Διαδίκτυο, επιβάλλοντας νομοθετικά αυτό που σε άλλα μέσα επικοινωνίας (π.χ. στο τηλέφωνο) θεωρούνται αυτονόητα: το δικαίωμα δύο ανθρώπων να χρησιμοποιούν το «μέσο» για να επικοινωνήσουν με τη σχετική ασφάλεια ότι δεν έχει, όχι πολύ εύκολα τουλάχιστον, το σύμπαν ολόκληρο τη δυνατότητα να κρυφακούει τι λένε, να καταγράφει και να χρησιμοποιεί για οποιοδήποτε σκοπό το περιεχόμενο της συνομιλίας, κοκ.

Ακόμη κι αγνοήσουμε αυτό το πρώτο μέρος, όμως, η γνωμοδότηση έτσι όπως παρουσιάζεται στην «Καθημερινή» έχει κάποια ακόμη σχετικά εμφανή προβλήματα. Το ένα από αυτά είναι περισσότερο νομικής φύσης, και δε μπορώ να προσποιηθώ ότι γνωρίζω τα πάντα σχετικά με το θέμα, αλλά κάποιες σχετικές σκέψεις μπορώ να τις καταγράψω εδώ.

Μέχρι σήμερα, όταν κάποιος ανταλλάσει χειρόγραφη αλληλογραφία με ένα φίλο του, όταν χρησιμοποιεί το τηλέφωνό του για να μιλήσει με συγγενείς, ή όταν στέλνει ένα δέμα με φαγητό στο γιό του σε μια άλλη πόλη, θεωρεί ότι είναι νομικά κατοχυρωμένο το δικαίωμά του στην «ιδιωτικότητα» της επικοινωνίας. Δε μπορούμε να είμαστε ποτέ 100% σίγουροι με αυτά τα πράγματα, αλλά μου φαίνεται ότι θα είμαστε προ των πυλών μιας μεγάλης έκτασης αντίδρασης αν κάποια στιγμή ανακοίνωνε το Ελληνικό κράτος ότι «όλες οι τηλεφωνικές συνομιλίες θα πρέπει να καταγράφονται από τις εταιρείες τηλεπικοινωνιών, και να είναι στη διακριτική ευχέρεια της Δικαιοσύνης να ζητήσει, χωρίς κανένα άλλο έλεγχο, ούτε καν από την ΑΔΑΕ, τα πλήρη στοιχεία τόσο των ατόμων που επικοινώνησαν, όσο και το περιεχόμενο της συνομιλίας». Το ίδιο έντονη και μεγάλης έκτασης πιθανολογώ ότι θα ήταν η αντίδραση αν κατοχυρωνόταν νομικά για το Ελληνικό κράτος ότι «κάθε δέμα ή γράμμα ή άλλο αντικείμενο που στέλνεται με ταχυδρομείο ή άλλη εταιρεία παροχής υπηρεσιών μεταφοράς θα ανοίγεται και το περιεχόμενό του θα καταγράφεται, έτσι ώστε να είναι διαθέσιμη αυτή η πληροφορία, οποιαδήποτε στιγμή, σε όποιον ζητήσει να την έχει, χωρίς να μπορεί η ΑΔΑΕ να διαμαρτυρηθεί ή να ασκήσει έλεγχο».

Το Διαδίκτυο μπορεί κι αυτό να χρησιμοποιηθεί για προσωπική επικοινωνία μεταξύ δύο ή περισσότερων ατόμων. Για την ακρίβεια, όχι μόνο μπορεί να χρησιμοποιηθεί για επικοινωνία, με τον συμβατικό τρόπο, μεταξύ δύο μόνο ατόμων, αλλά έχει κάνει δυνατές και βιώσιμες μορφές επικοινωνίας οι οποίες μέχρι πριν σχετικά λίγα χρόνια ήταν είτε αδύνατες, είτε ασύμφορες. Έχει ανοίξει έτσι νέους ορίζοντες τόσο στην προσωπική όσο και την κοινωνική ζωή εκατομμυρίων ανθρώπων στον πλανήτη. Ο λόγος για τον οποίο μπορεί, έτσι απλά — μια τόσο ευέλικτη μορφή επικοινωνίας, μια τόσο σημαντική και με τεράστια επιρροή στην κοινωνία — να μείνει χωρίς προστασία της ιδιωτικότητας από το υπάρχον νομικό πλαίσιο, μου διαφεύγει εντελώς αυτή τη στιγμή. Μου φαίνεται απλά αδιανόητο, αλλά μπορεί να μου ξεφεύγει κάτι πολύ βασικό.

Το δεύτερο πρόβλημα είναι «τεχνικής» φύσης, κι αγγίζει, επιπλέον, κάπως επιφανειακά αλλά με ολοφάνερο τρόπο, τα όρια της επιχειρηματικότητας. Ακόμη κι αν ξεπεραστεί το «κοινωνικό» και νομικό πρόβλημα που εισάγει μια πρόταση με τόσο εύρος και έκταση επιδράσεων όσο η φράση «το απόρρητο των επικοινωνιών δεν καλύπτει την επικοινωνία μέσω του διαδικτύου», ακόμη κι αν κατοχυρωθεί νομικά ως απαίτηση του Ελληνικού κράτους και προϋπόθεση για την λειτουργία ενός παροχέα διαδικτυακών υπηρεσιών η καταγραφή τόσο των «στοιχείων» κάθε επικοινωνίας όσο και, σε κάποιο βαθμό, το περιεχόμενο κάθε επικοινωνίας, υπάρχει α) το τεχνικό πρόβλημα του πώς ακριβώς θα γίνει αυτό και β) πώς θα αποθηκευθεί τόσος όγκος πληροφορίας σε ένα Ελληνικό παροχέα υπηρεσιών διαδικτύου.

Το πρώτο από αυτά τα δύο τεχνικά προβλήματα φαίνεται απλοϊκό, αλλά η μέχρι τώρα εμπειρία μου έχει δείξει ότι δεν είναι τόσο απλό όσο μπορεί να δείχνει αρχικά. Το τεχνικό υπόβαθρο για κάτι τέτοιο υπάρχει μεν, αλλά είτε είναι σε σχετικά εμβρϋικό στάδιο ή έχει κάποια τεχνικής φύσεως όρια, τα οποία θα είναι μαζί μας για ένα μη αμελητέο χρονικό διάστημα. Όπως και να έχει θα έχει ενδιαφέρον να δούμε πώς ακριβώς μπορεί κάθε Ελληνικός παροχέας διαδικτυακών υπηρεσιών να κρατάει πληροφορίες για κάθε μία από τις χιλιάδες συνδέσεις που μπορεί να κάνει την ώρα οποιοσδήποτε από τους εκατομμύρια υπολογιστές υπάρχουν σε όλη τη χώρα.

Ανάλογο με τον όγκο της πληροφορίας που απαιτεί η καταγραφή αυτή και το χρόνο για τον οποίο θα πρέπει να διατηρείται ένα μέρος αυτών των πληροφοριών (από μερικές ώρες, μέχρι μήνες ή και χρόνια), μπορεί να είναι τόσο τεράστια τα μεγέθη σε αποθηκευτικό χώρο που να είναι α) απαγορευτικό το κόστος του αποθηκευτικού χώρου, β) ασύμφορη η αναζήτηση πληροφορίας, η συσχέτιση των διαφορετικών μερών της, κλπ. Τεράστιες εταιρείες, όπως η Google, μπορεί να έχουν τη δυνατότητα να αποθηκεύουν αστρονομικά μεγέθη πληροφοριών, αλλά μπορεί να το κάνει αυτό κάθε ένας Ελληνικός παροχέας δικτυακών υπηρεσιών; Αν όχι, μήπως αυτό αποτελέσει, σε βάθος χρόνου, σημαντική τροχοπέδη στη δυνατότητα νέων & μικρών τηλεπικοινωνιακών εταιρειών στο σύνολο της χώρας;

Το δεύτερο τεχνικό πρόβλημα είναι ότι ένα μέρος από τα «στοιχεία» που θεωρεί ο κ. Σανιδάς απαραίτητα ως μέρος της καταγραφής είναι από πολύ δύσκολο έως πρακτικά αδύνατον να βρεθούν. Είναι τέτοιος ο τρόπος που λειτουργεί το Διαδίκτυο σήμερα που ο ίδιος υπολογιστής μπορεί να συνδεθεί, σε διαφορετικές στιγμές της ίδιας μέρας, από πολύ διαφορετικά μέρη. Για παράδειγμα, οποιοσδήποτε μπορεί να έχει μια σύνδεση με την εταιρεία «Forthnet» στο σπίτι του. Αυτή τη μία σύνδεση τη μοιράζεται όλη η οικογένεια, και υπάρχουν τουλάχιστον 5 διαφορετικοί «υπολογιστές» στο ίδιο σπίτι: 1) ο φορητός του πατέρα, τον οποίο του τον έχει δώσει η εταιρεία στην οποία δουλεύει, 2) ένας μικρός υποφορητός υπολογιστής, τον οποίο χρησιμοποιεί ο γιός της οικογένειας για να μοιράζεται φωτογραφίες με τους φίλους του και να μιλάει στο facebook, 3) ένας σταθερός υπολογιστής Macintosh, στον οποίο γράφει το επόμενο βιβλίο της η μάνα της οικογένειας, η οποία είναι συγγραφέας, 4) δύο κινητά τηλέφωνα με δυνατότητες ασύρματης σύνδεσης, τα οποία ενίοτε χρησιμοποιούνται και ως μίνι συσκευές πλοήγησης στο Διαδίκτυο, και τέλος 5) ένα σύστημα αναπαραγωγής πολυμέσων, με δυνατότητα σύνδεσης στο Διαδίκτυο και αναζήτηση πληροφοριών για ταινίες και μουσική σε βάσεις όπως η IMDB, το MTV και άλλες.

Οποιοσδήποτε από αυτούς τους φορητούς υπολογιστές μπορεί το πρωί να συνδεθεί από το σπίτι, το μεσημέρι από μια καφετέρια στο κέντρο της πόλης, το απόγευμα από το ασύρματο δίκτυο του λιμανιού για αναζήτηση πληροφοριών για ταξιδιωτικά προγράμματα, κοκ. Κάθε φορά που ένας από τους μεταφέρσιμους υπολογιστές «αλλάζει δίκτυο» χρησιμοποιεί την εκάστοτε σύνδεση, η οποία φαίνεται (από νομικής πλευράς τουλάχιστον) να ανήκει και σε διαφορετικό «αγοραστή», μπορεί να είναι σε οποιονδήποτε παροχέα υπηρεσιών Internet και σίγουρα έχει διαφορετική δικτυακή διεύθυνση και διεύθυνση στον «φυσικό» κόσμο, εκτός δικτύου από οποιαδήποτε άλλη σύνδεση χρησιμοποιεί η ίδια οικογένεια.

Ακόμη κι αν υπάρχει κάτι επιλήψιμο σε κάποιες από τις ενέργειες ενός από τα μέλη της οικογένειας που περιγράψαμε μόλις, δεν υπάρχει (τουλάχιστον αυτή τη στιγμή) κάποιος καλός τρόπος να πιστοποιηθεί ποιό από τα μέλη ήταν αυτό, όταν είναι μαζί, και ακόμη περισσότερο όταν έχουν σκορπίσει κατά τη διάρκεια της ημέρας τους σε όλο σχεδόν το εύρος μιας πόλης δεκάδων χιλιάδων ή εκατομμυρίων κατοίκων.

Αυτό το πρόβλημα της αντιστοίχησης ενός υπολογιστή με μια νομική οντότητα — όπως ένα πρόσωπο με συγκεκριμένα στοιχεία, όνομα, διεύθυνση, ηλικία, και γενικά οτιδήποτε μπορεί να πιστοποιήσει την ταυτότητα κάποιου — περιγράφεται πολύ καλά στο βιβλίο “Code version 2.0″ του Lawrence Lessig. Μερικά αποσπάσματα από το βιβλίο, τα οποία φαίνεται να έχουν άμεση σχέση με το πώς, ποιός, πότε, πόσο και γιατί θα πρέπει να «ελέγχει το δίκτυο» είναι τα εξής:

“As I describe in the first chapter, the dominant idea among those who raved about cyberspace then was that cyberspace was beyond the reach of real-space regulation.”

“In the years since, that common view has faded. The confidence of the Internet exceptionalists has waned. The idea—and even the desire—that the Internet would remain unregulated is gone.”

“Cyberspace was increasingly everywhere, but it was very hard for those in the audience to imagine it tamed to serve the ends of government. And at that time, commerce was certainly interested in cyberspace, though credit card companies were still warning customers to stay far away from the Net. The Net was an exploding social space of something. But it was hard to see it as an exploding space of social control.”

Ολόκληρο το βιβλίο περιγράφει τις αλληλεπιδράσεις που μπορεί να έχουν δύο σημαντικές δυνάμεις με δυνητικά φοβερή επίδραση στην κοινωνία: ο Νόμος και το Εμπόριο.

Ο Νόμος ως «κώδικας», ως «πηγαίος κώδικας» του Κράτους, ως η «υλοποίηση» του Κράτους, αφού ο Νόμος είναι η οντότητα η οποία έχει άμεση επίδραση και επιρροή στον σχηματισμό και τη λειτουργία της κοινωνίας στον φυσικό κόσμο. Ο Νόμος, επίσης ως δύναμη επιρροής και ελέγχου του τι «μπορεί» και τι «επιτρέπεται» να κάνει το Εμπόριο.

Το Εμπόριο, από την άλλη, ως ενεργοποιός και κατευθυντήρια δύναμη, η οποία δίνει τόσο τη δυνατότητα (μέσω άμεσης ή έμμεσης χρηματοδότησης για την υλοποίηση και εφαρμογή μιας τεχνολογίας). Το Εμπόριο σε συμβουλευτικό ρόλο για το Νόμο, με τις de facto υλοποιήσεις ιδεών και πρακτικών, οι οποίες είτε δεν καλύπτονται πλήρως ακόμη ή δεν έχουν προβλεφθεί από το υπάρχοντα Νόμο.

Αρχίζοντας από αυτό το πλαίσιο το “Code version 2.0″ εξελλίσεται γρήγορα σε ένα συναρπαστικό βιβλίο. Καταφέρνει να παρουσιάσει ορισμένα κρίσιμα θέματα από τεχνική, νομική, ηθική και κοινωνική άποψη. Είναι από τα βιβλία που ξαναδιαβάζω συχνά, απλά γιατί μου αρέσει τόσο πολύ κι επειδή κάθε φορά ανακαλύπτω λεπτομέρειες τις οποίες δεν είχα προσέξει παλιότερα.

Ένα από τα παραδείγματα του βιβλίου έχει σχέση με την ταυτοποίηση κάποιου στο δίκτυο. Είναι πολύ καλή περιγραφή των απαιτήσεων που φαίνεται να έχει η γνωμοδότηση του κ. Σανιδά, οπότε το παραθέτω εδώ αυτούσιο, με μερικά σχόλια στο τέλος.


Is the Way it is the Way it Must Be?

If there was a meme that ruled talk about cyberspace, it was that cyberspace was a place that could not be regulated. That it “cannot be governed”; that its “nature” is to resist regulation. Not that cyberspace cannot be broken, or that government cannot shut it down. But if cyberspace exists, so first-generation thinking goes, government’s power over behavior there is quite limited. In its essence, cyberspace is a space of no control.

Nature. Essence. Innate. The way things are. This kind of rhetoric should raise suspicions in any context. It should especially raise suspicion here. If there is any place where nature has no rule, it is in cyberspace. If there is any place that is constructed, cyberspace is it. Yet the rhetoric of “essence” hides this constructedness. It misleads our intuitions in dangerous ways.

This is the fallacy of “is-ism”—the mistake of confusing how something is with how it must be. There is certainly a way that cyberspace is. But how cyberspace is is not how cyberspace has to be. There is no single way that the Net has to be; no single architecture that defines the nature of the Net. The possible architectures of something that we would call “the Net” are many, and the character of life within those different architectures is diverse.

That most of us commit this fallacy is not surprising. Most of us haven’t a clue about how networks work. We therefore have no clue about how they could be different. We assume that the way we find things is the way things have to be. We are not trained to think about all the different ways technology could achieve the same ends through different means. That sort of training is what technologists get. Most of us are not technologists.

But underlying everything in this book is a single normative plea: that all of us must learn at least enough to see that technology is plastic. It can be remade to do things differently. And that if there is a mistake that we who know too little about technology should make, it is the mistake of imagining technology to be too plastic, rather than not plastic enough. We should expect—and demand—that it can be made to reflect any set of values that we think important. The burden should be on the technologists to show us why that demand can’t be met.

The particular is-ism that I begin with here is the claim that cyberspace can’t be regulated. As this, and the following chapters argue, that view is wrong. Whether cyberspace can be regulated depends upon its architecture. The original architecture of the Internet made regulation extremely difficult. But that original architecture can change. And there is all the evidence in the world that it is changing. Indeed, under the architecture that I believe will emerge, cyberspace will be the most regulable space humans have ever known. The “nature” of the Net might once have been its unregulability; that “nature” is about to flip.

To see the flip, you must first see a contrast between two different cyber-places. These two cyber-places are ideal types, and, indeed, one of the two ideals no longer exists anywhere on the Net. That fact is confirmation of the point this section aims to make: that we’re moving from one Internet to another, and the one we’re moving to will be significantly more regulable.

The following descriptions are not technical; I don’t offer them as complete definitions of types of networks or types of control. I offer them to illustrate—to sketch enough to see a far more general point.

CYBER-PLACES: HARVARD VERSUS CHICAGO

The Internet was born at universities in the United States. Its first subscribers were researchers. But as a form of life, its birth was tied to university life. It swept students online, pulling them away from life in real space. The Net was one of many intoxicants on college campuses in the mid-1990s, and its significance only grew through time. As former “New York Times” columnist J. C. Herz wrote in her first book about cyberspace:

When I look up, it’s four-thirty in the morning. “No way.” I look from the clock to my watch. Way. I’ve been in front of this screen for six hours, and it seems like no time at all. I’m not even remotely tired. Dazed and thirsty, but not tired. In fact, I’m euphoric. I stuff a disheveled heap of textbooks, photocopied articles, hilighters and notes into my backpack and run like a madwoman up the concrete steps, past the security guard, and outside into the predawn mist . . .

I stop where a wet walkway meets a dry one and stand for a sec . . .  [I] start thinking about this thing that buzzes around the entire world, through the phone lines, all day and all night long. It’s right under our noses and it’s invisible. It’s like Narnia, or Magritte, or Star Trek, an entire goddamned world. Except it doesn’t physically exist. It’s just the collective consciousness of however many people are on it. This really is outstandingly weird.

Yet not all universities adopted the Net in the same way. Or put differently, the access universities granted was not all the same. The rules were different. The freedoms allowed were different. One example of this difference comes from two places I knew quite well, though many other examples could make the same point.

In the middle 1990s at the University of Chicago, if you wanted access to the Internet, you simply connected your machine to Ethernet jacks located throughout the university. Any machine with an Ethernet connection could be plugged into these jacks. Once connected, your machine had full access to the Internet — access, that is, that was complete, anonymous, and free.

The reason for this freedom was a decision by an administrator —the then-Provost, Geoffrey Stone, a former dean of the law school and a prominent free speech scholar. When the university was designing its net, the technicians asked Stone whether anonymous communication should be permitted. Stone, citing the principle that the rules regulating speech at the university should be as protective of free speech as the First Amendment, said yes: People should have the right to communicate at the university anonymously, because the First Amendment to the Constitution guarantees the same right vis-à-vis governments. From that policy decision flowed the architecture of the University of Chicago’s net.

At Harvard, the rules are different. If you plug your machine into an Ethernet jack at the Harvard Law School, you will not gain access to the Net. You cannot connect your machine to the Net at Harvard unless the machine is registered—licensed, approved, verified. Only members of the university community can register their machines. Once registered, all interactions with the network are monitored and identified to a particular machine. To join the network, users have to “sign” a user agreement. The agreement acknowledges this pervasive practice of monitoring. Anonymous speech on this network is not permitted — it is against the rules. Access can be controlled based on who you are, and interactions can be traced based on what you did.

This design also arose from the decision of an administrator, one less focused on the protections of the First Amendment. Control was the ideal at Harvard; access was the ideal at Chicago. Harvard chose technologies that made control possible; Chicago chose technologies that made access easy.

These two networks differ in at least two important ways. First and most obviously, they differ in the values they embrace. That difference is by design. At the University of Chicago, First Amendment values determined network design; different values determined Harvard’s design.

But they differ in a second way as well. Because access is controlled at Harvard and identity is known, actions can be traced back to their root in the network. Because access is not controlled at Chicago, and identity is not known, actions cannot be traced back to their root in the network. Monitoring or tracking behavior at Chicago is harder than it is at Harvard. Behavior in the Harvard network is more controllable than in the University of Chicago network.

The networks thus differ in the extent to which they make behavior within each network regulable. This difference is simply a matter of code —a difference in the software and hardware that grants users access. Different code makes differently regulable networks. Regulability is thus a function of design.

Με αυτό το πολύ απλό παράδειγμα, ο Lawrence Lessig παρουσιάζει, λοιπόν, την άποψή του ότι το Διαδίκτυο δεν είναι «εγγενώς» ελεύθερο. Είναι τόσο ελεύθερο όσο επιλέγουμε ΕΜΕΙΣ να το κάνουμε.

Η σημαντική λεπτομέρεια εδώ είναι πως «εμείς» στη συγκεκριμένη περίπτωση είναι ο κ. Σανιδάς και οποιοσδήποτε άλλος έχει τη δυνατότητα να επηρεάσει το νομοθετικό έργο.

Οπότε η δική μου, μάλλον αφελής, γνώμη σχετικά με τη γνωμοδότηση αυτή έχει τουλάχιστον δύο μέρη:

Κατ’ αρχήν μια έκκληση σε όσους βιάζονται να σχολιάσουν ότι «η πληροφορία θέλει να είναι ελεύθερη» ή ότι «το διαδίκτυο γεννήθηκε ελεύθερο και θα παραμείνει ελεύθερο ότι και να κάνουν οι ‘κακοί’ άλλοι»: μην έχετε τόσο σιγουριά ότι το διαδίκτυο γεννήθηκε ελεύθερο ή ότι, για κάποιο μυστηριακό λόγο, έχει μέσα του τα ψήγματα μιας τόσο ανώτερης ελευθερίας που δεν την αγγίζει τίποτα. Την αγγίζουν πολλά πράγματα. Ορισμένα, μάλιστα, από αυτά την έχουν ήδη καταφάει σα σαράκι από μέσα, και μόνο με πολλή προσπάθεια θα μπορέσει να συνέρθει, να πάρει τη μορφή που θέλουμε και να παραμείνει ζωντανή. Διαβάστε το “Code version 2.0″. Μετά ξαναδιαβάστε το. Είναι από τα πιο σημαντικά βιβλία που έχω βρει τα τελευταία 5 χρόνια για την ελευθερία στο διαδίκτυο, και γι αυτό το συνιστώ ανεπιφύλακτα. Ακόμη, αν έχετε κι εσείς με τη σειρά σας κάτι να μου προτείνετε για ενημέρωση, μη διστάσετε. Στείλτε το με email.

Τέλος μια παράκληση στον κ. Σανιδά: Πριν αφορίσουμε κάθε είδους ιδιωτικότητα, ελευθερία και δυνατότητα έκφρασης από το Διαδίκτυο, ας το σκεφτούμε λίγο. Αξίζει τον κόπο, γιατί το Διαδίκτυο που θα φτιάξουμε εμείς σήμερα δεν ανήκει σε εμάς. Ανήκει στις επόμενες γενιές, κι εμείς το δανειζόμαστε προσωρινά από αυτές. Τους χρωστάμε την καλύτερη προσπάθεια που μπορούμε να κάνουμε :)

Ενημέρωση (2 Ιουλ 2009): Η Έλενα Σπυροπούλου έχει κάνει ένα πολύ ωραίο και αναλυτικό σχολιασμό στο κείμενο της γνωμοδότησης: http://www.elenaspiropoulou.gr/node/106

2009-06-28

FreeBSD doc-el picking up speed

As pleasures go, it is a strange yet somewhat refined one to see a project one has started pick up speed. My fellow translators at the Greek documentation team of FreeBSD have been busy lately, and the result of our collective work is a fairly large number of commits to the “doc-el” repository.

There are now at least four translators actively working on a chapter of their own: Manolis Kiagias, Vaggelis Typaldos, Kyriakos Kentrotis and me. Changesets flow between our repository clones almost every day, and I often find myself pulling patches from two or three places at the same time.

This morning I picked up patches from both Kyriakos and Manolis. Manolis had already integrated with Vaggelis, so pulling from him I also got the translations of Vaggelis. In the meantime, my nightly cron job had finished importing a new snapshot from the official CVS tree, so today’s history graph looks scary:

Greek FreeBSD Translations: Commit History of 28 June 2009

The “surface complexity” of a change history like this may seem scary, but to me it is nothing of the sort. It is, in fact, quite the opposite: something to be proud and happy about, because it shows a lively team, working steadily towards our common goal—a fully translated doc/ tree with a translated, accessible version of the FreeBSD Handbook for Greek users.

It really makes me very happy to see an effort started several years ago gain momentum. My own personal commits are far less than those of the other translators now, and I often find myself in the role of a “patch integrator” instead of actively translating new text. But this is ok, because now we have more people working on the translations so we still get many improvements every day :-)

2009-06-15

Apparently Elephants and FreeBSD are Quite Popular

Looking at the search terms that people used to reach this weblog, I noticed that one of the most popular posts of all time is the “Contributing to FreeBSD” post of Feb 2009.

Search terms for this weblog

This is fantastic! I didn’t realize readers of this weblog would like the particular post so much, but I am extremely pleased you did!

Puzzle: Student grades and other amusements

Filed under: Misc — keramida @ 02:51:19
Tags:

An interesting problem was described to me by a friend last night.

Let us assume that there is a semi-fictional school, where a number of students start studying every year. The number of new students ranges between 70 and 150 every year.

The students can pick more than the strictly required number of classes during their few final terms. They get rated in all their optional classes, and just before graduating the students have the option of keeping some of the optional classes and aborting others.

Each time they pick or drop one of the optional classes, there is a system in place that immediatelly replies with their placement in the graduation list, depending on their final score in the selected set of classes.

The school now uses a very peculiar algorithm for selecting a number of the graduating students to cover some of the prestiguous positions for teaching assistants. There are 5 types of positions: A, B, C, D and E. The academic prestige, future options and monetary gains from each type of position are very well-defined, and there is a clear order of preference: A > B > C > D > E.

The peculiar algorithm for picking graduating students for each type of these teaching assistant positions is:

  • After all students have picked a set of class grades, and their graduation placement has been fixed, a ballot is drawn between the numbers 15, 16, 17, 18, 29 and 20.
  • The number N drawn from the ballot is used to split the graduating students in teams of N members, starting from the one with the highest grades as student #1, the second as #2, … the N-th as the last member of the first team, the (N+1)-th as the first member of the second team, and so on.
  • Then the first five students of each team are chosen for the five job position types: the first team member for an A position, the second for a B position, etc.

This is a very strange algorithm for selecting students for the five types teaching assistant positions. At first glance someone may be tempted to say that it is `fair’, because of the ballot. My intuition says this isn’t true, however. So the questions this discussion triggered were:

  • How “fair” is this selection algorithm?
  • Are there positions in the graduation order of all students that are favored a lot by this sort of selection process?
  • If there are positions that do have an advantage, how many are they and what is their overall distribution in the range of [1..150] students of each year?

I spent a bit of time last night trying to work this out, and I think I have an answer now. Before I post how I tried to answer, what are your thoughts? How would you approach this ‘problem’?

2009-06-05

query-replace-regexp or “making movies enjoyable”

One of the movies I recently watched came with subtitles in a separate *.srt file. The subtitles had 99% correct timing information, a pretty amazing feat. They had a minor glitch though. Many instances of lowercase ‘el’ had been replaced with uppercase ‘i’.

I noticed this tiny glitch in the first few lines of text, and then discovered that it was a buglet that occured far too often. My OCD side started feeling bad about the movie, because all the bogus capital ‘i’ letters were distracting me from the “real” fun of watching the actual movie.

So I stopped watching, and I fired up GNU Emacs on the srt file.

After 1-2 minutes of work, and a lot of fun with query-replace-regexp I found a nice replacement pattern to interactively fix all the broken ‘i’ instances:

M-x query-replace-regexp RET
    \([^I ]*\)\(I+\)\([^I ]*\) RET
    \1\,(replace-regexp-in-string "i" "l" (downcase \2))\3 RET

This had quite a few false positives, but it did 95% of the work, so I manually fixed the 5-10 instances it didn’t catch, and I was finally able to enjoy the movie.

Note: The perceptive reader who is also a fan of regular expressions will probably notice very quickly that part of the third line is Lisp code. This is an amazing feature of regexp replacement in Emacs. When the special pattern \, appears in the replacement text it evaluates the following expression as Emacs Lisp. An arbitrarily complex Lisp expression can be used after \, and its return value is used as the replacement text.

I’m positively thrilled that Emacs saved the day… again :-)

2009-06-04

Dear Santa…

Filed under: Computers, Mercurial, Programming, Software — keramida @ 08:25:03
Tags: , , ,

I know it’s a bit early for 2010, but can you please grant me a wish today and count it as one of the 2010 ones?

For 2010 (and the rest of 2009) I wish I can keep up today’s pace of reading code, hacking at it, running tests and then committing; and be able to do that almost every day:

$ hg  log --template '{date|isodate} {author|user}\n' | \
    fgrep 'keramida' | awk '{print $1,$4}' | sort | uniq -c | tail -2
  10 2009-06-01 keramida
  26 2009-06-04 keramida

Oh, and yeah… I’ll be a good boy ;-)

2009-06-02

Η Αποκρουστέα Μυθολογία

Filed under: Γλωσσικά — keramida @ 04:22:56
Tags:

Με μια μικρή καθυστέρηση, διάβασα σήμερα το εξαιρετικό άρθρο “Η Αποκρουστέα Μυθολογία” του Δημήτρη Σαραντάκου:

http://www.emprosnet.gr/Opinions/articles/?EntityID=8aafe47e-40b1-4ad8-ad5d-cea9aa138eb8

Υπέροχο, πραγματικά, το άρθρο. Αντάξιο της γραφής στην οποία μας έχει συνηθίσει ένας εξίσου υπέροχος άνθρωπος.

2009-05-30

Με στενοχωρεί κάπως…

Filed under: Misc, Γλωσσικά — keramida @ 09:56:33
Tags: ,

Με στενοχωρεί κάπως να βλέπω ανθρώπους με κατάρτιση πανεπιστημιακού επιπέδου να κάνουν τέτοια λάθη:

Απόσπασμα άρθρου από το meafora.gr

(more…)

2009-05-27

Η Οικονομική Κρίση Χτυπάει και στο IRC

Filed under: Fun — keramida @ 09:12:59

Χωρίς σχόλια…

12:03 <lompas> error c2177: constant too big
12:04 <keramida> μάλλον το παράκανες με τα μηδενικά :P
12:05 <lompas> ναι έκοψα μερικά και τρέχει
12:05 <keramida> κρίση και στο coding
12:06 <vvas> lol
12:06 <vvas> περικοπές ε
12:06 <keramida> ναι, κανονικά :)
Next Page »

Blog at WordPress.com.