Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework config file location #126

Merged
merged 6 commits into from
Sep 29, 2014
Merged

Rework config file location #126

merged 6 commits into from
Sep 29, 2014

Conversation

mildred
Copy link
Contributor

@mildred mildred commented Sep 25, 2014

Implement IPFS_CONFIG_DIR and refactor code to make it simpler. Fix bug in -c option handling in init subcommand, and add -c support to config subcommand.

Also add ipfs init -d option to change default datastore location when initializing ipfs.

@@ -36,16 +36,26 @@ type Config struct {
Peers []*SavedPeer // local nodes's bootstrap peers
}

const DefaultPathRoot = "~/.go-ipfs"
const DefaultConfigFilePath = DefaultPathRoot + "/config"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep these as constants, defined here.

@jbenet
Copy link
Member

jbenet commented Sep 25, 2014

hey @mildred thanks for the PR. made some comments, pls address those, and then we can merge

@mildred
Copy link
Contributor Author

mildred commented Sep 25, 2014

I tried to fix all the issues raised in the comments, any more remarks?

@jbenet
Copy link
Member

jbenet commented Sep 25, 2014

LGTM @whyrusleeping ?

// empty string is provided for `configroot`, the default root is used.
func Path(configroot, extension string) (string, error) {
if len(configroot) == 0 {
dir, err := PathRoot()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks funky... it seems that if we error, we shouldnt bother doing the join

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, want to return "" on error

@jbenet
Copy link
Member

jbenet commented Sep 26, 2014

@mildred almost there! two last comments from @whyrusleeping up there ^

@jbenet jbenet added the status/in-progress In progress label Sep 26, 2014
@mildred
Copy link
Contributor Author

mildred commented Sep 26, 2014

@jbenet do you think this is ok ?

@jbenet
Copy link
Member

jbenet commented Sep 26, 2014

@mildred LGTM-- if you've tested it?
seems like all comments addressed. I'll have to merge it manually unless you rebase on top of new master. (if you're not comfortable rebasing, I can do it)

@whyrusleeping
Copy link
Member

LGTM

@mildred
Copy link
Contributor Author

mildred commented Sep 26, 2014

I might not have time to rebase this in the next two days. Feel free to do it, or I could do it some time around Monday.

@mildred
Copy link
Contributor Author

mildred commented Sep 26, 2014

I had time to do the rebase, here it is. But doing further tests, I noticed an issue: when creating directories, it creates directories with mode 000, and you get a permission denied.

Sorry, it's not ready yet.

}
cfg.Datastore.Path = dspath
cfg.Datastore.Type = "leveldb"

// Construct the data store if missing
if err := os.MkdirAll(dspath, os.ModeDir); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use os.ModeDir | 0555

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used os.ModePerm (0777). I don't think 0555 is enough, you don't have write permissions.

Talking about permissions, perhaps we should store the private key a little bit more securely (0600 permission for example)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0555 is plenty, ipfs is read only. just make sure you binary OR it with os.ModeDir.

As for making the private key a little more secure, i agree completely. If you want to throw that on this PR, that works for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The private key will be encrypted later on. Fs permissions won't do much for us.


Sent from Mailbox

On Fri, Sep 26, 2014 at 1:30 PM, Jeromy Johnson notifications@github.com
wrote:

 }
 cfg.Datastore.Path = dspath
 cfg.Datastore.Type = "leveldb"
  • // Construct the data store if missing
  • if err := os.MkdirAll(dspath, os.ModeDir); err != nil {
    0555 is plenty, ipfs is read only. just make sure you binary OR it with os.ModeDir.
    As for making the private key a little more secure, i agree completely. If you want to throw that on this PR, that works for me.

Reply to this email directly or view it on GitHub:
https://github.com/jbenet/go-ipfs/pull/126/files#r18111981

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it would prevent some other user from altering the key in the file. Which is never a bad thing (ssh does this, even if the keys are encrypted)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore what i said about 0555... i forgot we were dealing with config dirs for some reason... (os.ModeDir | 0777) should work.

Shanti Bouchez-Mongardé added 6 commits September 29, 2014 21:54
Removed config.Filename and replace it with config.GetConfigFilePath that
takes a configuration directory as argument instead. Makes code simpler.
ipfs.getConfigDir now also return the default configuration dir instead of
an empty string in some cases.
@mildred
Copy link
Contributor Author

mildred commented Sep 29, 2014

I rebased this pull request. is there anything preventing this pull request from being merged?

@jbenet
Copy link
Member

jbenet commented Sep 29, 2014

@mildred all LGTM 👍

jbenet added a commit that referenced this pull request Sep 29, 2014
Rework config file location
@jbenet jbenet merged commit f223aef into ipfs:master Sep 29, 2014
@jbenet jbenet removed the status/in-progress In progress label Sep 29, 2014
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this pull request Oct 23, 2021
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Feb 25, 2022
add custom DNS Resolver configuration
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Feb 25, 2022
…olver

add custom DNS Resolver configuration
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Mar 4, 2022
…olver

add custom DNS Resolver configuration
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Mar 4, 2022
…olver

add custom DNS Resolver configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants