]> arthur.barton.de Git - bup.git/blob - lib/bup/metadata.py
Accommodate missing owner or group name during metadata save/restore.
[bup.git] / lib / bup / metadata.py
1 """Metadata read/write support for bup."""
2
3 # Copyright (C) 2010 Rob Browning
4 #
5 # This code is covered under the terms of the GNU Library General
6 # Public License as described in the bup LICENSE file.
7
8 import errno, os, sys, stat, pwd, grp, struct, xattr, posix1e, re
9
10 from cStringIO import StringIO
11 from bup import vint
12 from bup.drecurse import recursive_dirlist
13 from bup.helpers import add_error, mkdirp, log
14 from bup.xstat import utime, lutime, lstat, FSTime
15 import bup._helpers as _helpers
16
17 if _helpers.get_linux_file_attr:
18     from bup._helpers import get_linux_file_attr, set_linux_file_attr
19
20 # WARNING: the metadata encoding is *not* stable yet.  Caveat emptor!
21
22 # Q: Consider hardlink support?
23 # Q: Is it OK to store raw linux attr (chattr) flags?
24 # Q: Can anything other than S_ISREG(x) or S_ISDIR(x) support posix1e ACLs?
25 # Q: Is the application of posix1e has_extended() correct?
26 # Q: Is one global --numeric-ids argument sufficient?
27 # Q: Do nfsv4 acls trump posix1e acls? (seems likely)
28 # Q: Add support for crtime -- ntfs, and (only internally?) ext*?
29
30 # FIXME: Fix relative/abs path detection/stripping wrt other platforms.
31 # FIXME: Add nfsv4 acl handling - see nfs4-acl-tools.
32 # FIXME: Consider other entries mentioned in stat(2) (S_IFDOOR, etc.).
33 # FIXME: Consider pack('vvvvsss', ...) optimization.
34 # FIXME: Consider caching users/groups.
35
36 ## FS notes:
37 #
38 # osx (varies between hfs and hfs+):
39 #   type - regular dir char block fifo socket ...
40 #   perms - rwxrwxrwxsgt
41 #   times - ctime atime mtime
42 #   uid
43 #   gid
44 #   hard-link-info (hfs+ only)
45 #   link-target
46 #   device-major/minor
47 #   attributes-osx see chflags
48 #   content-type
49 #   content-creator
50 #   forks
51 #
52 # ntfs
53 #   type - regular dir ...
54 #   times - creation, modification, posix change, access
55 #   hard-link-info
56 #   link-target
57 #   attributes - see attrib
58 #   ACLs
59 #   forks (alternate data streams)
60 #   crtime?
61 #
62 # fat
63 #   type - regular dir ...
64 #   perms - rwxrwxrwx (maybe - see wikipedia)
65 #   times - creation, modification, access
66 #   attributes - see attrib
67
68 verbose = 0
69
70 _have_lchmod = hasattr(os, 'lchmod')
71
72
73 def _clean_up_path_for_archive(p):
74     # Not the most efficient approach.
75     result = p
76
77     # Take everything after any '/../'.
78     pos = result.rfind('/../')
79     if(pos != -1):
80         result = result[result.rfind('/../') + 4:]
81
82     # Take everything after any remaining '../'.
83     if result.startswith("../"):
84         result = result[3:]
85
86     # Remove any '/./' sequences.
87     pos = result.find('/./')
88     while pos != -1:
89         result = result[0:pos] + '/' + result[pos + 3:]
90         pos = result.find('/./')
91
92     # Remove any leading '/'s.
93     result = result.lstrip('/')
94
95     # Replace '//' with '/' everywhere.
96     pos = result.find('//')
97     while pos != -1:
98         result = result[0:pos] + '/' + result[pos + 2:]
99         pos = result.find('//')
100
101     # Take everything after any remaining './'.
102     if result.startswith('./'):
103         result = result[2:]
104
105     # Take everything before any remaining '/.'.
106     if result.endswith('/.'):
107         result = result[:-2]
108
109     if result == '' or result.endswith('/..'):
110         result = '.'
111
112     return result
113
114
115 def _risky_path(p):
116     if p.startswith('/'):
117         return True
118     if p.find('/../') != -1:
119         return True
120     if p.startswith('../'):
121         return True
122     if p.endswith('/..'):
123         return True
124     return False
125
126
127 def _clean_up_extract_path(p):
128     result = p.lstrip('/')
129     if result == '':
130         return '.'
131     elif _risky_path(result):
132         return None
133     else:
134         return result
135
136
137 # These tags are currently conceptually private to Metadata, and they
138 # must be unique, and must *never* be changed.
139 _rec_tag_end = 0
140 _rec_tag_path = 1
141 _rec_tag_common = 2           # times, owner, group, type, perms, etc.
142 _rec_tag_symlink_target = 3
143 _rec_tag_posix1e_acl = 4      # getfacl(1), setfacl(1), etc.
144 _rec_tag_nfsv4_acl = 5        # intended to supplant posix1e acls?
145 _rec_tag_linux_attr = 6       # lsattr(1) chattr(1)
146 _rec_tag_linux_xattr = 7      # getfattr(1) setfattr(1)
147
148
149 class MetadataError(Exception):
150     pass
151
152
153 class MetadataAcquireError(MetadataError):
154     # Thrown when unable to extract any given bit of metadata from a path.
155     pass
156
157
158 class MetadataApplyError(MetadataError):
159     # Thrown when unable to apply any given bit of metadata to a path.
160     pass
161
162
163 class Metadata:
164     # Metadata is stored as a sequence of tagged binary records.  Each
165     # record will have some subset of add, encode, load, create, and
166     # apply methods, i.e. _add_foo...
167
168     ## Common records
169
170     # Timestamps are (sec, ns), relative to 1970-01-01 00:00:00, ns
171     # must be non-negative and < 10**9.
172
173     def _add_common(self, path, st):
174         self.mode = st.st_mode
175         self.uid = st.st_uid
176         self.gid = st.st_gid
177         self.rdev = st.st_rdev
178         self.atime = st.st_atime
179         self.mtime = st.st_mtime
180         self.ctime = st.st_ctime
181         self.owner = self.group = ''
182         try:
183             self.owner = pwd.getpwuid(st.st_uid)[0]
184         except KeyError, e:
185             add_error(e)
186         try:
187             self.group = grp.getgrgid(st.st_gid)[0]
188         except KeyError, e:
189             add_error(e)
190
191     def _encode_common(self):
192         atime = self.atime.to_timespec()
193         mtime = self.mtime.to_timespec()
194         ctime = self.ctime.to_timespec()
195         result = vint.pack('VVsVsVvVvVvV',
196                            self.mode,
197                            self.uid,
198                            self.owner,
199                            self.gid,
200                            self.group,
201                            self.rdev,
202                            atime[0],
203                            atime[1],
204                            mtime[0],
205                            mtime[1],
206                            ctime[0],
207                            ctime[1])
208         return result
209
210     def _load_common_rec(self, port):
211         data = vint.read_bvec(port)
212         (self.mode,
213          self.uid,
214          self.owner,
215          self.gid,
216          self.group,
217          self.rdev,
218          self.atime,
219          atime_ns,
220          self.mtime,
221          mtime_ns,
222          self.ctime,
223          ctime_ns) = vint.unpack('VVsVsVvVvVvV', data)
224         self.atime = FSTime.from_timespec((self.atime, atime_ns))
225         self.mtime = FSTime.from_timespec((self.mtime, mtime_ns))
226         self.ctime = FSTime.from_timespec((self.ctime, ctime_ns))
227
228     def _create_via_common_rec(self, path, create_symlinks=True):
229         # If the path already exists and is a dir, try rmdir.
230         # If the path already exists and is anything else, try unlink.
231         st = None
232         try:
233             st = lstat(path)
234         except IOError, e:
235             if e.errno != errno.ENOENT:
236                 raise
237         if st:
238             if stat.S_ISDIR(st.st_mode):
239                 try:
240                     os.rmdir(path)
241                 except OSError, e:
242                     if e.errno == errno.ENOTEMPTY:
243                         msg = 'refusing to overwrite non-empty dir' + path
244                         raise Exception(msg)
245                     raise
246             else:
247                 os.unlink(path)
248
249         if stat.S_ISREG(self.mode):
250             os.mknod(path, 0600 | stat.S_IFREG)
251         elif stat.S_ISDIR(self.mode):
252             os.mkdir(path, 0700)
253         elif stat.S_ISCHR(self.mode):
254             os.mknod(path, 0600 | stat.S_IFCHR, self.rdev)
255         elif stat.S_ISBLK(self.mode):
256             os.mknod(path, 0600 | stat.S_IFBLK, self.rdev)
257         elif stat.S_ISFIFO(self.mode):
258             os.mknod(path, 0600 | stat.S_IFIFO)
259         elif stat.S_ISLNK(self.mode):
260             if(self.symlink_target and create_symlinks):
261                 os.symlink(self.symlink_target, path)
262         # FIXME: S_ISDOOR, S_IFMPB, S_IFCMP, S_IFNWK, ... see stat(2).
263         # Otherwise, do nothing.
264
265     def _apply_common_rec(self, path, restore_numeric_ids=False):
266         # FIXME: S_ISDOOR, S_IFMPB, S_IFCMP, S_IFNWK, ... see stat(2).
267         if stat.S_ISLNK(self.mode):
268             lutime(path, (self.atime, self.mtime))
269         else:
270             utime(path, (self.atime, self.mtime))
271         if stat.S_ISREG(self.mode) \
272                 | stat.S_ISDIR(self.mode) \
273                 | stat.S_ISCHR(self.mode) \
274                 | stat.S_ISBLK(self.mode) \
275                 | stat.S_ISLNK(self.mode) \
276                 | stat.S_ISFIFO(self.mode):
277             # Be safe.
278             if _have_lchmod:
279                 os.lchmod(path, 0)
280             elif not stat.S_ISLNK(self.mode):
281                 os.chmod(path, 0)
282
283             # Don't try to restore owner unless we're root, and even
284             # if asked, don't try to restore the owner or group if
285             # it doesn't exist in the system db.
286             uid = self.uid
287             gid = self.gid
288             if not restore_numeric_ids:
289                 if not self.owner:
290                     uid = -1
291                     add_error('bup: ignoring missing owner for "%s"\n' % path)
292                 else:
293                     if os.geteuid() != 0:
294                         uid = -1 # Not root; assume we can't change owner.
295                     else:
296                         try:
297                             uid = pwd.getpwnam(self.owner)[2]
298                         except KeyError:
299                             uid = -1
300                             fmt = 'bup: ignoring unknown owner %s for "%s"\n'
301                             add_error(fmt % (self.owner, path))
302                 if not self.group:
303                     gid = -1
304                     add_error('bup: ignoring missing group for "%s"\n' % path)
305                 else:
306                     try:
307                         gid = grp.getgrnam(self.group)[2]
308                     except KeyError:
309                         gid = -1
310                         add_error('bup: ignoring unknown group %s for "%s"\n'
311                                   % (self.group, path))
312             os.lchown(path, uid, gid)
313
314             if _have_lchmod:
315                 os.lchmod(path, stat.S_IMODE(self.mode))
316             elif not stat.S_ISLNK(self.mode):
317                 os.chmod(path, stat.S_IMODE(self.mode))
318
319
320     ## Path records
321
322     def _encode_path(self):
323         if self.path:
324             return vint.pack('s', self.path)
325         else:
326             return None
327
328     def _load_path_rec(self, port):
329         self.path = vint.unpack('s', vint.read_bvec(port))[0]
330
331
332     ## Symlink targets
333
334     def _add_symlink_target(self, path, st):
335         if(stat.S_ISLNK(st.st_mode)):
336             self.symlink_target = os.readlink(path)
337
338     def _encode_symlink_target(self):
339         return self.symlink_target
340
341     def _load_symlink_target_rec(self, port):
342         self.symlink_target = vint.read_bvec(port)
343
344
345     ## POSIX1e ACL records
346
347     # Recorded as a list:
348     #   [txt_id_acl, num_id_acl]
349     # or, if a directory:
350     #   [txt_id_acl, num_id_acl, txt_id_default_acl, num_id_default_acl]
351     # The numeric/text distinction only matters when reading/restoring
352     # a stored record.
353     def _add_posix1e_acl(self, path, st):
354         if not stat.S_ISLNK(st.st_mode):
355             try:
356                 if posix1e.has_extended(path):
357                     acl = posix1e.ACL(file=path)
358                     self.posix1e_acl = [acl, acl] # txt and num are the same
359                     if stat.S_ISDIR(st.st_mode):
360                         acl = posix1e.ACL(filedef=path)
361                         self.posix1e_acl.extend([acl, acl])
362             except EnvironmentError, e:
363                 if e.errno != errno.EOPNOTSUPP:
364                     raise
365
366     def _encode_posix1e_acl(self):
367         # Encode as two strings (w/default ACL string possibly empty).
368         if self.posix1e_acl:
369             acls = self.posix1e_acl
370             txt_flags = posix1e.TEXT_ABBREVIATE
371             num_flags = posix1e.TEXT_ABBREVIATE | posix1e.TEXT_NUMERIC_IDS
372             acl_reps = [acls[0].to_any_text('', '\n', txt_flags),
373                         acls[1].to_any_text('', '\n', num_flags)]
374             if(len(acls) < 3):
375                 acl_reps += ['', '']
376             else:
377                 acl_reps.append(acls[2].to_any_text('', '\n', txt_flags))
378                 acl_reps.append(acls[3].to_any_text('', '\n', num_flags))
379             return vint.pack('ssss',
380                              acl_reps[0], acl_reps[1], acl_reps[2], acl_reps[3])
381         else:
382             return None
383
384     def _load_posix1e_acl_rec(self, port):
385         data = vint.read_bvec(port)
386         acl_reps = vint.unpack('ssss', data)
387         if(acl_reps[2] == ''):
388             acl_reps = acl_reps[:2]
389         self.posix1e_acl = [posix1e.ACL(x) for x in acl_reps]
390
391     def _apply_posix1e_acl_rec(self, path, restore_numeric_ids=False):
392         if(self.posix1e_acl):
393             acls = self.posix1e_acl
394             if(len(acls) > 2):
395                 if restore_numeric_ids:
396                     acls[3].applyto(path, posix1e.ACL_TYPE_DEFAULT)
397                 else:
398                     acls[2].applyto(path, posix1e.ACL_TYPE_DEFAULT)
399             if restore_numeric_ids:
400                 acls[1].applyto(path, posix1e.ACL_TYPE_ACCESS)
401             else:
402                 acls[0].applyto(path, posix1e.ACL_TYPE_ACCESS)
403
404
405     ## Linux attributes (lsattr(1), chattr(1))
406
407     def _add_linux_attr(self, path, st):
408         if stat.S_ISREG(st.st_mode) or stat.S_ISDIR(st.st_mode):
409             attr = get_linux_file_attr(path)
410             if(attr != 0):
411                 self.linux_attr = get_linux_file_attr(path)
412
413     def _encode_linux_attr(self):
414         if self.linux_attr:
415             return vint.pack('V', self.linux_attr)
416         else:
417             return None
418
419     def _load_linux_attr_rec(self, port):
420         data = vint.read_bvec(port)
421         self.linux_attr = vint.unpack('V', data)[0]
422
423     def _apply_linux_attr_rec(self, path, restore_numeric_ids=False):
424         if(self.linux_attr):
425             set_linux_file_attr(path, self.linux_attr)
426
427
428     ## Linux extended attributes (getfattr(1), setfattr(1))
429
430     def _add_linux_xattr(self, path, st):
431         try:
432             self.linux_xattr = xattr.get_all(path, nofollow=True)
433         except EnvironmentError, e:
434             if e.errno != errno.EOPNOTSUPP:
435                 raise
436
437     def _encode_linux_xattr(self):
438         if self.linux_xattr:
439             result = vint.pack('V', len(self.linux_xattr))
440             for name, value in self.linux_xattr:
441                 result += vint.pack('ss', name, value)
442             return result
443         else:
444             return None
445
446     def _load_linux_xattr_rec(self, file):
447         data = vint.read_bvec(file)
448         memfile = StringIO(data)
449         result = []
450         for i in range(vint.read_vuint(memfile)):
451             key = vint.read_bvec(memfile)
452             value = vint.read_bvec(memfile)
453             result.append((key, value))
454         self.linux_xattr = result
455
456     def _apply_linux_xattr_rec(self, path, restore_numeric_ids=False):
457         if(self.linux_xattr):
458             for k, v in self.linux_xattr:
459                 xattr.set(path, k, v, nofollow=True)
460
461     def __init__(self):
462         # optional members
463         self.path = None
464         self.symlink_target = None
465         self.linux_attr = None
466         self.linux_xattr = None
467         self.posix1e_acl = None
468         self.posix1e_acl_default = None
469
470     def write(self, port, include_path=True):
471         records = [(_rec_tag_path, self._encode_path())] if include_path else []
472         records.extend([(_rec_tag_common, self._encode_common()),
473                         (_rec_tag_symlink_target, self._encode_symlink_target()),
474                         (_rec_tag_posix1e_acl, self._encode_posix1e_acl()),
475                         (_rec_tag_linux_attr, self._encode_linux_attr()),
476                         (_rec_tag_linux_xattr, self._encode_linux_xattr())])
477         for tag, data in records:
478             if data:
479                 vint.write_vuint(port, tag)
480                 vint.write_bvec(port, data)
481         vint.write_vuint(port, _rec_tag_end)
482
483     @staticmethod
484     def read(port):
485         # This method should either: return a valid Metadata object;
486         # throw EOFError if there was nothing at all to read; throw an
487         # Exception if a valid object could not be read completely.
488         tag = vint.read_vuint(port)
489         try: # From here on, EOF is an error.
490             result = Metadata()
491             while(True): # only exit is error (exception) or _rec_tag_end
492                 if tag == _rec_tag_path:
493                     result._load_path_rec(port)
494                 elif tag == _rec_tag_common:
495                     result._load_common_rec(port)
496                 elif tag == _rec_tag_symlink_target:
497                     result._load_symlink_target_rec(port)
498                 elif tag == _rec_tag_posix1e_acl:
499                     result._load_posix1e_acl(port)
500                 elif tag ==_rec_tag_nfsv4_acl:
501                     result._load_nfsv4_acl_rec(port)
502                 elif tag == _rec_tag_linux_attr:
503                     result._load_linux_attr_rec(port)
504                 elif tag == _rec_tag_linux_xattr:
505                     result._load_linux_xattr_rec(port)
506                 elif tag == _rec_tag_end:
507                     return result
508                 else: # unknown record
509                     vint.skip_bvec(port)
510                 tag = vint.read_vuint(port)
511         except EOFError:
512             raise Exception("EOF while reading Metadata")
513
514     def isdir(self):
515         return stat.S_ISDIR(self.mode)
516
517     def create_path(self, path, create_symlinks=True):
518         self._create_via_common_rec(path, create_symlinks=create_symlinks)
519
520     def apply_to_path(self, path=None, restore_numeric_ids=False):
521         # apply metadata to path -- file must exist
522         if not path:
523             path = self.path
524         if not path:
525             raise Exception('Metadata.apply_to_path() called with no path');
526         num_ids = restore_numeric_ids
527         try: # Later we may want to push this down and make it finer grained.
528             self._apply_common_rec(path, restore_numeric_ids=num_ids)
529             self._apply_posix1e_acl_rec(path, restore_numeric_ids=num_ids)
530             self._apply_linux_attr_rec(path, restore_numeric_ids=num_ids)
531             self._apply_linux_xattr_rec(path, restore_numeric_ids=num_ids)
532         except Exception, e:
533             raise MetadataApplyError(e), None, sys.exc_info()[2]
534
535
536 def from_path(path, archive_path=None, save_symlinks=True):
537     result = Metadata()
538     result.path = archive_path
539     st = lstat(path)
540     try: # Later we may want to push this down and make it finer grained.
541         result._add_common(path, st)
542         if(save_symlinks):
543             result._add_symlink_target(path, st)
544         result._add_posix1e_acl(path, st)
545         result._add_linux_attr(path, st)
546         result._add_linux_xattr(path, st)
547     except Exception, e:
548         raise MetadataAcquireError(e), None, sys.exc_info()[2]
549     return result
550
551
552 def save_tree(output_file, paths,
553               recurse=False,
554               write_paths=True,
555               save_symlinks=True,
556               xdev=False):
557
558     # Issue top-level rewrite warnings.
559     for path in paths:
560         safe_path = _clean_up_path_for_archive(path)
561         if(safe_path != path):
562             log('bup: archiving "%s" as "%s"\n' % (path, safe_path))
563
564     start_dir = os.getcwd()
565     try:
566         for (p, st) in recursive_dirlist(paths, xdev=xdev):
567             dirlist_dir = os.getcwd()
568             os.chdir(start_dir)
569             safe_path = _clean_up_path_for_archive(p)
570             try:
571                 m = from_path(p, archive_path=safe_path,
572                               save_symlinks=save_symlinks)
573             except MetadataAcquireError, e:
574                 add_error(e)
575
576             if verbose:
577                 print >> sys.stderr, m.path
578             m.write(output_file, include_path=write_paths)
579             os.chdir(dirlist_dir)
580     finally:
581         os.chdir(start_dir)
582
583
584 def _set_up_path(meta, create_symlinks=True):
585     # Allow directories to exist as a special case -- might have
586     # been created by an earlier longer path.
587     if meta.isdir():
588         mkdirp(meta.path, 0700)
589     else:
590         parent = os.path.dirname(meta.path)
591         if parent:
592             mkdirp(parent, 0700)
593             meta.create_path(meta.path, create_symlinks=create_symlinks)
594
595
596 class _ArchiveIterator:
597     def next(self):
598         try:
599             return Metadata.read(self._file)
600         except EOFError:
601             raise StopIteration()
602
603     def __iter__(self):
604         return self
605
606     def __init__(self, file):
607         self._file = file
608
609
610 def display_archive(file):
611     for meta in _ArchiveIterator(file):
612         if verbose:
613             print meta.path # FIXME
614         else:
615             print meta.path
616
617
618 def start_extract(file, create_symlinks=True):
619     for meta in _ArchiveIterator(file):
620         if verbose:
621             print >> sys.stderr, meta.path
622         xpath = _clean_up_extract_path(meta.path)
623         if not xpath:
624             add_error(Exception('skipping risky path "%s"' % meta.path))
625         else:
626             meta.path = xpath
627             _set_up_path(meta, create_symlinks=create_symlinks)
628
629
630 def finish_extract(file, restore_numeric_ids=False):
631     all_dirs = []
632     for meta in _ArchiveIterator(file):
633         xpath = _clean_up_extract_path(meta.path)
634         if not xpath:
635             add_error(Exception('skipping risky path "%s"' % dir.path))
636         else:
637             if os.path.isdir(meta.path):
638                 all_dirs.append(meta)
639             else:
640                 if verbose:
641                     print >> sys.stderr, meta.path
642                 try:
643                     meta.apply_to_path(path=xpath,
644                                        restore_numeric_ids=restore_numeric_ids)
645                 except MetadataApplyError, e:
646                     add_error(e)
647
648     all_dirs.sort(key = lambda x : len(x.path), reverse=True)
649     for dir in all_dirs:
650         # Don't need to check xpath -- won't be in all_dirs if not OK.
651         xpath = _clean_up_extract_path(dir.path)
652         if verbose:
653             print >> sys.stderr, dir.path
654         try:
655             dir.apply_to_path(path=xpath,
656                               restore_numeric_ids=restore_numeric_ids)
657         except MetadataApplyError, e:
658             add_error(e)
659
660
661 def extract(file, restore_numeric_ids=False, create_symlinks=True):
662     # For now, just store all the directories and handle them last,
663     # longest first.
664     all_dirs = []
665     for meta in _ArchiveIterator(file):
666         xpath = _clean_up_extract_path(meta.path)
667         if not xpath:
668             add_error(Exception('skipping risky path "%s"' % meta.path))
669         else:
670             meta.path = xpath
671             if verbose:
672                 print >> sys.stderr, '+', meta.path
673             _set_up_path(meta, create_symlinks=create_symlinks)
674             if os.path.isdir(meta.path):
675                 all_dirs.append(meta)
676             else:
677                 if verbose:
678                     print >> sys.stderr, '=', meta.path
679                 try:
680                     meta.apply_to_path(restore_numeric_ids=restore_numeric_ids)
681                 except MetadataApplyError, e:
682                     add_error(e)
683     all_dirs.sort(key = lambda x : len(x.path), reverse=True)
684     for dir in all_dirs:
685         # Don't need to check xpath -- won't be in all_dirs if not OK.
686         xpath = _clean_up_extract_path(meta.path)
687         if verbose:
688             print >> sys.stderr, '=', meta.path
689         # Shouldn't have to check for risky paths here (omitted above).
690         try:
691             dir.apply_to_path(path=dir.path,
692                               restore_numeric_ids=restore_numeric_ids)
693         except MetadataApplyError, e:
694             add_error(e)