QList<KUserGroup> KUser::groups() const { QList<KUserGroup> result; Q_FOREACH (const QString &name, groupNames()) { result.append(KUserGroup(name)); }
QList<KUserGroup> KUser::groups(uint maxCount) const { QList<KUserGroup> result; listGroupsForUser( d->loginName.toLocal8Bit().constData(), d->gid, maxCount, [&](const group * g) { result.append(KUserGroup(g)); } ); return result; }
void KFileItemPrivate::init() { m_access.clear(); // metaInfo = KFileMetaInfo(); // stat() local files if needed // TODO: delay this until requested if (m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown || m_entry.count() == 0) { if (m_url.isLocalFile()) { /* directories may not have a slash at the end if * we want to stat() them; it requires that we * change into it .. which may not be allowed * stat("/is/unaccessible") -> rwx------ * stat("/is/unaccessible/") -> EPERM H.Z. * This is the reason for the StripTrailingSlash */ QT_STATBUF buf; const QString path = m_url.adjusted(QUrl::StripTrailingSlash).toLocalFile(); const QByteArray pathBA = QFile::encodeName(path); if (QT_LSTAT(pathBA.constData(), &buf) == 0) { m_entry.insert(KIO::UDSEntry::UDS_DEVICE_ID, buf.st_dev); m_entry.insert(KIO::UDSEntry::UDS_INODE, buf.st_ino); mode_t mode = buf.st_mode; if ((buf.st_mode & QT_STAT_MASK) == QT_STAT_LNK) { m_bLink = true; if (QT_STAT(pathBA, &buf) == 0) { mode = buf.st_mode; } else {// link pointing to nowhere (see FileProtocol::createUDSEntry() in ioslaves/file/file.cpp) mode = (QT_STAT_MASK - 1) | S_IRWXU | S_IRWXG | S_IRWXO; } } m_entry.insert(KIO::UDSEntry::UDS_SIZE, buf.st_size); m_entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, buf.st_mode & QT_STAT_MASK); // extract file type m_entry.insert(KIO::UDSEntry::UDS_ACCESS, buf.st_mode & 07777); // extract permissions m_entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, buf.st_mtime); // TODO: we could use msecs too... m_entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, buf.st_atime); #ifndef Q_OS_WIN m_entry.insert(KIO::UDSEntry::UDS_USER, KUser(buf.st_uid).loginName()); m_entry.insert(KIO::UDSEntry::UDS_GROUP, KUserGroup(buf.st_gid).name()); #endif // TODO: these can be removed, we can use UDS_FILE_TYPE and UDS_ACCESS everywhere if (m_fileMode == KFileItem::Unknown) { m_fileMode = mode & QT_STAT_MASK; // extract file type } if (m_permissions == KFileItem::Unknown) { m_permissions = mode & 07777; // extract permissions } } } } }
QList<KUserGroup> KUserGroup::allGroups() { QList<KUserGroup> result; ::group* g; while ((g = getgrent())) { result.append(KUserGroup(g)); } endgrent(); return result; }
QList<KUserGroup> KUserGroup::allGroups(uint maxCount) { QList<KUserGroup> result; ::group *g; setgrent(); for (uint i = 0; i < maxCount && (g = getgrent()); ++i) { result.append(KUserGroup(g)); } endgrent(); return result; }
Smb4KCustomOptions::Smb4KCustomOptions() : d(new Smb4KCustomOptionsPrivate) { d->type = UnknownNetworkItem; d->remount = UndefinedRemount; d->smbPort = 139; #if defined(Q_OS_LINUX) d->fileSystemPort = 445; d->securityMode = UndefinedSecurityMode; d->writeAccess = UndefinedWriteAccess; #endif d->kerberos = UndefinedKerberos; d->user = KUser(KUser::UseRealUserID); d->group = KUserGroup(KUser::UseRealUserID); d->wol_first_scan = false; d->wol_mount = false; }
Smb4KCustomOptions::Smb4KCustomOptions(Smb4KHost *host) : d(new Smb4KCustomOptionsPrivate) { d->workgroup = host->workgroupName(); d->url = host->url(); d->type = Host; d->remount = UndefinedRemount; d->smbPort = host->port() != -1 ? host->port() : 139; #if defined(Q_OS_LINUX) d->fileSystemPort = 445; d->securityMode = UndefinedSecurityMode; d->writeAccess = UndefinedWriteAccess; #endif d->kerberos = UndefinedKerberos; d->user = KUser(KUser::UseRealUserID); d->group = KUserGroup(KUser::UseRealUserID); d->ip.setAddress(host->ip()); d->wol_first_scan = false; d->wol_mount = false; }
bool Smb4KCustomOptions::isEmpty() { // Type if (d->type != UnknownNetworkItem) { return false; } else { // Do nothing } // Profile if (!d->profile.isEmpty()) { return false; } else { // Do nothing } // Workgroup if (!d->workgroup.isEmpty()) { return false; } else { // Do nothing } // URL if (!d->url.isEmpty()) { return false; } else { // Do nothing } // IP address if (!d->ip.isNull()) { return false; } else { // Do nothing } // Remounting if (d->remount != Smb4KCustomOptions::UndefinedRemount) { return false; } else { // Do nothing } // SMB port if (d->smbPort != 139) { return false; } else { // Do nothing } #if defined(Q_OS_LINUX) // File system port (used for mounting) if (d->fileSystemPort != 445) { return false; } else { // Do nothing } // Security mode if (d->securityMode != Smb4KCustomOptions::UndefinedSecurityMode) { return false; } else { // Do nothing } // Write access if (d->writeAccess != UndefinedWriteAccess) { return false; } else { // Do nothing } #endif // Kerberos if (d->kerberos != UndefinedKerberos) { return false; } else { // Do nothing } // UID if (d->user.userId() != KUser(KUser::UseRealUserID).userId()) { return false; } else { // Do nothing } // GID if (d->group.groupId() != KUserGroup(KUser::UseRealUserID).groupId()) { return false; } else { // Do nothing } // MAC address if (!d->mac.isNull()) { return false; } else { // Do nothing } // Send WOL packages before first scan if (d->wol_first_scan) { return false; } else { // Do nothing } // Send WOL packages before mount if (d->wol_mount) { return false; } else { // Do nothing } return true; }