小编Pau*_*aul的帖子

存储linux守护程序所需的密码

我编写了一个linux守护程序,它将(并且必须)以root身份运行.当它运行时,不一定会有任何人登录,因为它是由cron启动的.该守护进程需要存储一些URL,uid和密码,因为它连接到其他服务器(如dropbox,google,windows server等).

问:存储这些密码的最佳位置和方法是什么.

我无法存储哈希值,因为我需要原始url/uid/pwd来连接到远程服务.

我只能看到两个选项:

a)gnome-keyring-daemon
据我所知,这需要登录用户/会话.我已经尝试从我的守护进程(以root身份)启动它,收集返回的环境变量并尝试连接到它.到目前为止,这已失败.
b)root拥有的只读文件.
这也可以使用(例如)hostid加密,但最重要的是这种方法依赖于默认和root访问.

还有其他选择吗?
非常感谢.

linux encryption passwords daemon root

5
推荐指数
1
解决办法
3446
查看次数

插入图像后 NSTextView 不更新

我的应用程序(swift、OSX、Xcode,所有东西的最新版本)都有一个 NSTextView,我允许用户输入。NSTextView 启用了 RichText、图形和 NSInspectorBar。

我将 NSTextView 的内容加载/保存为 webarchive 格式(抱怨 - 但我需要一种包含图像的便携式格式)。

到现在为止还挺好。一切正常......除了一个小细节。当我将图像插入 TextView 时,它不显示。但它就在那里,因为如果我保存和加载......它就会出现。

这是我将图像插入 NSTextView 的方法(我从 NSOpenPanel 获取图像的路径:

    guard let theImage = NSImage(contentsOfURL: openPanel.URL!) else   {
        showErrorMessage("Unable to load image")
        return
    }
    // self.textEditor is the NSTextView
    guard let store = self.textEditor.textStorage else { abort() }

    let attachment = NSTextAttachment()
    attachment.image = theImage
    let attrString = NSAttributedString(attachment: attachment)       

    let range = self.textEditor.selectedRange()
    store.replaceCharactersInRange(range, withAttributedString: attrString)
Run Code Online (Sandbox Code Playgroud)

我认为它相当简单:加载图像,添加到一个属性字符串,用属性字符串替换选定的字符。

然而什么也没有出现。NSTextView 完全没有变化。如果我将 NSTextStorage 内容保存为 webarchive:

    guard let store = textEditor.textStorage else { …
Run Code Online (Sandbox Code Playgroud)

macos swift

5
推荐指数
1
解决办法
958
查看次数

标签 统计

daemon ×1

encryption ×1

linux ×1

macos ×1

passwords ×1

root ×1

swift ×1