This file is indexed.

/usr/share/gnome-shell/js/misc/smartcardManager.js is in gnome-shell-common 3.10.4-0ubuntu5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-

const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Signals = imports.signals;

const ObjectManager = imports.misc.objectManager;

const SmartcardTokenIface = '<node> \
<interface name="org.gnome.SettingsDaemon.Smartcard.Token"> \
  <property name="Name" type="s" access="read"/> \
  <property name="Driver" type="o" access="read"/> \
  <property name="IsInserted" type="b" access="read"/> \
  <property name="UsedToLogin" type="b" access="read"/> \
</interface> \
</node>';

let _smartcardManager = null;

function getSmartcardManager() {
    if (_smartcardManager == null)
        _smartcardManager = new SmartcardManager();

    return _smartcardManager;
}

const SmartcardManager = new Lang.Class({
    Name: 'SmartcardManager',
    _init: function() {
        this._objectManager = new ObjectManager.ObjectManager({ connection: Gio.DBus.session,
                                                                name: "org.gnome.SettingsDaemon.Smartcard",
                                                                objectPath: '/org/gnome/SettingsDaemon/Smartcard',
                                                                knownInterfaces: [ SmartcardTokenIface ],
                                                                onLoaded: Lang.bind(this, this._onLoaded) });
        this._insertedTokens = {};
        this._loginToken = null;
    },

    _onLoaded: function() {
        let tokens = this._objectManager.getProxiesForInterface('org.gnome.SettingsDaemon.Smartcard.Token');

        for (let i = 0; i < tokens.length; i++)
            this._addToken(tokens[i]);

        this._objectManager.connect('interface-added', Lang.bind(this, function(objectManager, interfaceName, proxy) {
            if (interfaceName == 'org.gnome.SettingsDaemon.Smartcard.Token')
                this._addToken(proxy);
        }));

        this._objectManager.connect('interface-removed', Lang.bind(this, function(objectManager, interfaceName, proxy) {
            if (interfaceName == 'org.gnome.SettingsDaemon.Smartcard.Token')
                this._removeToken(proxy);
        }));
    },

    _updateToken: function(token) {
        let objectPath = token.get_object_path();

        delete this._insertedTokens[objectPath];

        if (token.IsInserted)
            this._insertedTokens[objectPath] = token;

        if (token.UsedToLogin)
            this._loginToken = token;
    },

    _addToken: function(token) {
        this._updateToken(token);

        token.connect('g-properties-changed',
                      Lang.bind(this, function(proxy, properties) {
                          if ('IsInserted' in properties.deep_unpack()) {
                              this._updateToken(token);

                              if (token.IsInserted) {
                                  this.emit('smartcard-inserted', token);
                              } else {
                                  this.emit('smartcard-removed', token);
                              }
                          }
                      }));

        // Emit a smartcard-inserted at startup if it's already plugged in
        if (token.IsInserted)
            this.emit('smartcard-inserted', token);
    },

    _removeToken: function(token) {
        let objectPath = token.get_object_path();

        if (this._insertedTokens[objectPath] == token) {
            delete this._insertedTokens[objectPath];
            this.emit('smartcard-removed', token);
        }

        if (this._loginToken == token)
            this._loginToken = null;

        token.disconnectAll();
    },

    hasInsertedTokens: function() {
        return Object.keys(this._insertedTokens).length > 0;
    },

    hasInsertedLoginToken: function() {
        if (!this._loginToken)
            return false;

        if (!this._loginToken.IsInserted)
            return false;

        return true;
    }

});
Signals.addSignalMethods(SmartcardManager.prototype);