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

DT doesn't save setting between sessions #72

Closed
travelerspb opened this issue Mar 29, 2018 · 54 comments · Fixed by #261
Closed

DT doesn't save setting between sessions #72

travelerspb opened this issue Mar 29, 2018 · 54 comments · Fixed by #261
Labels

Comments

@travelerspb
Copy link

Macos, v39.3.0
Not sure if its a bug or feature but every time I run the program, it set all setting to default. For example I can check option "Dont display children", restart Therapist, and it will be unchecked again.

@cvuchener
Copy link
Contributor

Check the permissions of "~/.config/UDP Software/Dwarf Therapist.ini", it may be owned by root (falcn's issue).

@travelerspb
Copy link
Author

@cvuchener it's -rw-r--r-- 1 root, so had to change it manually and it works now. But I definitely never started as root, why would I do that on Mac

@cvuchener
Copy link
Contributor

I don't know MacOS well. There is some platform-specific code that request authorization. But I don't know how to make it use the privileges only for reading DF memory and not for writing files.

@falcn
Copy link

falcn commented Apr 3, 2018

sudo chmod go+w ~/.config/UDP\ Software/Dwarf\ Therapist.ini fixes the problem. Is it possible to create it with group write permissions when DT runs for the first time?

@cvuchener
Copy link
Contributor

Making the file world writable is not a good solution. It should be owned by the regular user. If you change the owner (chown), does it stay that way or DT recreates a root owned file?

If it stays with the first owner, it should be possible to force the creation before the privileges are requested. But what about the other files created by DT (e.g. csv export must happen with privileges to get DF data)?

I am still confused by how these authorization rights work. What does the DFInstanceOSX::authorize method exactly do? Is it displaying a dialog for requesting root permissions and then setting the effective user id to 0 if it is accepted? It may be possible to switch between root and regular user with seteuid so root is only used when accessing DF memory.

@cvuchener
Copy link
Contributor

Can someone try this patch? Compilation was not tested and it may be missing includes (unistd.h for the uid stuff and string.h for strerror).

Run as a debug build or with -debug option, I would like to check the debug log line with the uids.

diff --git a/src/dfinstanceosx.h b/src/dfinstanceosx.h
index bd44bfc..3b9376b 100644
--- a/src/dfinstanceosx.h
+++ b/src/dfinstanceosx.h
@@ -54,6 +54,7 @@ private:
     VIRTADDR alloc_chunk(USIZE size);
     VIRTADDR m_alloc_start, m_alloc_end;
     int m_alloc_remaining, m_size_allocated;
+    uid_t m_ruid;
 };
 
 #endif // DFINSTANCE_H
diff --git a/src/dfinstanceosx.mm b/src/dfinstanceosx.mm
index 146f42d..c96c0d8 100644
--- a/src/dfinstanceosx.mm
+++ b/src/dfinstanceosx.mm
@@ -68,6 +68,21 @@ DFInstanceOSX::DFInstanceOSX(QObject* parent)
     if(!authorize()) {
         exit(1);
     }
+    uid_t ruid, euid, suid;
+    if (-1 == getresuid(&ruid, &euid, &suid)) {
+        int err = errno;
+        LOGE << "getresuid failed:" << strerror(err);
+        return;
+    }
+    LOGD << "ruid =" << ruid << ", euid =" << euid << ", suid =" << suid;
+    m_ruid = ruid;
+
+    // temporarily drop privileges
+    if (-1 == seteuid(m_ruid)) {
+        int err = errno;
+        LOGE << "seteuid failed:" << strerror(err);
+        return;
+    }
 }
 
 DFInstanceOSX::~DFInstanceOSX() {
@@ -83,6 +98,13 @@ bool DFInstanceOSX::attach() {
         return true;
     }
 
+    // reacquire dropped privileges
+    if (-1 == seteuid(0)) {
+        int err = errno;
+        LOGE << "seteuid(0) failed:" << strerror(err);
+        return false;
+    }
+
     result = task_suspend(m_task);
     if ( result != KERN_SUCCESS ) {
         return false;
@@ -98,8 +120,8 @@ bool DFInstanceOSX::detach() {
         return true;
     }
 
-    if( m_attach_count > 1 ) {
-        m_attach_count--;
+    m_attach_count--;
+    if( m_attach_count > 0 ) {
         return true;
     }
 
@@ -107,7 +129,13 @@ bool DFInstanceOSX::detach() {
     if ( result != KERN_SUCCESS ) {
         return false;
     }
-    m_attach_count--;
+
+    // temporarily drop privileges
+    if (-1 == seteuid(m_ruid)) {
+        int err = errno;
+        LOGE << "seteuid failed:" << strerror(err);
+        return false;
+    }
     return true;
 }

@ifreund
Copy link
Contributor

ifreund commented Apr 19, 2018

Will try this now

Edit:
Looks like the stuff you're trying to do with the uid stuff is deprecated/not supported.
I did include unistd.h
Probably something to do with macOS stemming from BSD not Linux.

/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:73:15: error: use of undeclared identifier 'getresuid'
    if (-1 == getresuid(&ruid, &euid, &suid)) {
              ^
/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:298:14: warning: 'AuthorizationExecuteWithPrivileges' is deprecated: first deprecated in
      macOS 10.7 [-Wdeprecated-declarations]
    status = AuthorizationExecuteWithPrivileges(authorizationRef, therapistExe,
             ^
/System/Library/Frameworks/Security.framework/Headers/Authorization.h:428:10: note: 'AuthorizationExecuteWithPrivileges' has been explicitly marked
      deprecated here
OSStatus AuthorizationExecuteWithPrivileges(AuthorizationRef authorization,
         ^
/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:325:21: warning: 'AuthorizationCopyPrivilegedReference' is deprecated: first deprecated in
      macOS 10.7 [-Wdeprecated-declarations]
    OSStatus stat = AuthorizationCopyPrivilegedReference(&myAuthRef,kAuthorizationFlagDefaults);
                    ^
/System/Library/Frameworks/Security.framework/Headers/Authorization.h:447:10: note: 'AuthorizationCopyPrivilegedReference' has been explicitly marked
      deprecated here
OSStatus AuthorizationCopyPrivilegedReference(AuthorizationRef __nullable * __nonnull authorization,
         ^
2 warnings and 1 error generated.
make[2]: *** [CMakeFiles/DwarfTherapist.dir/src/dfinstanceosx.mm.o] Error 1
make[1]: *** [CMakeFiles/DwarfTherapist.dir/all] Error 2
make: *** [all] Error 2

@cvuchener
Copy link
Contributor

Sorry, I did notice later that getresuid was specific to linux and I forgot to fix it.

Try this: https://github.com/cvuchener/Dwarf-Therapist/tree/macos-seteuid

It uses only getuid, geteuid and seteuid, they should exist on any POSIX system.

@ifreund
Copy link
Contributor

ifreund commented Apr 19, 2018

Not sure if it's because that branch is on 39.3.0 or if it's the permission changes but DT was unable to detect that DF 0.44.09 was running.

However, settings are saved between runs properly and the ini file is owned by the user:

-rw-r--r--  1 ifreund  staff  7817 Apr 19 13:45 Dwarf Therapist.ini

Built with -DCMAKE_BUILD_TYPE=Debug (pretty sure that's how it's done but I'm not great at cmake)

Compiler warnings:

/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:292:14: warning: 'AuthorizationExecuteWithPrivileges' is deprecated: first deprecated in
      macOS 10.7 [-Wdeprecated-declarations]
    status = AuthorizationExecuteWithPrivileges(authorizationRef, therapistExe,
             ^
/System/Library/Frameworks/Security.framework/Headers/Authorization.h:428:10: note: 'AuthorizationExecuteWithPrivileges' has been explicitly marked
      deprecated here
OSStatus AuthorizationExecuteWithPrivileges(AuthorizationRef authorization,
         ^
/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:319:21: warning: 'AuthorizationCopyPrivilegedReference' is deprecated: first deprecated in
      macOS 10.7 [-Wdeprecated-declarations]
    OSStatus stat = AuthorizationCopyPrivilegedReference(&myAuthRef,kAuthorizationFlagDefaults);
                    ^
/System/Library/Frameworks/Security.framework/Headers/Authorization.h:447:10: note: 'AuthorizationCopyPrivilegedReference' has been explicitly marked
      deprecated here
OSStatus AuthorizationCopyPrivilegedReference(AuthorizationRef __nullable * __nonnull authorization,
         ^
2 warnings generated.

Output:

"2018-Apr-19 13:48:29.431 INFO\tcore\tDwarf Therapist \"39.3.0\" starting normally. [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:186] (setup_logging)"
"2018-Apr-19 13:48:29.433 INFO\tcore\tRuntime QT Version 5.10.1 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:187] (setup_logging)"
"2018-Apr-19 13:48:30.057 DEBUG\tcore\tsetting up connections for MainWindow [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:166] (MainWindow)"
"2018-Apr-19 13:48:30.617 INFO\tcore\tbeginning to read settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:213] (read_settings)"
"2018-Apr-19 13:48:30.637 INFO\tcore\tfinished reading settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:264] (read_settings)"
"2018-Apr-19 13:48:30.692 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-19 13:48:30.693 WARNING\tcore\tNo valid layouts found in the following directories: (\"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/../share\", \"/Users/ifreund/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.appContents/Resources\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/share\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:126] (DFInstance)"

2018-04-19 13:48:30.693 DwarfTherapist[43631:9598427] Not authorized
"2018-Apr-19 13:48:36.626 INFO\tcore\tDwarf Therapist \"39.3.0\" starting normally. [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:186] (setup_logging)"
"2018-Apr-19 13:48:36.627 INFO\tcore\tRuntime QT Version 5.10.1 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:187] (setup_logging)"
"2018-Apr-19 13:48:37.244 DEBUG\tcore\tsetting up connections for MainWindow [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:166] (MainWindow)"
"2018-Apr-19 13:48:37.782 INFO\tcore\tbeginning to read settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:213] (read_settings)"
"2018-Apr-19 13:48:37.801 INFO\tcore\tfinished reading settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:264] (read_settings)"
"2018-Apr-19 13:48:37.862 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-19 13:48:37.862 WARNING\tcore\tNo valid layouts found in the following directories: (\"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/../share\", \"/Users/ifreund/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.appContents/Resources\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/share\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:126] (DFInstance)"
"2018-Apr-19 13:48:37.868 DEBUG\tcore\truid = 501 , euid = 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:72] (DFInstanceOSX)"
"2018-Apr-19 13:48:37.878 INFO\tcore\tFound running copy, pid: 42485 path: \"/Users/ifreund/Documents/df_osx/./dwarfort.exe\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:169] (set_pid)"
"2018-Apr-19 13:48:37.886 ERROR\tcore\tcan't find running copy [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:177] (set_pid)"
"2018-Apr-19 13:48:37.886 WARNING\tcore\tlost connection to DF [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:467] (lost_df_connection)"
"2018-Apr-19 13:48:37.888 ERROR\tcore\t(\"Not Running\", \"Unable to locate a running copy of Dwarf Fortress, are you sure it's running?\", \"\", \"\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:489] (lost_df_connection)"
ifreundair:build ifreund$ "2018-Apr-19 13:48:38.400 INFO\tcore\tNew version found \"39.3.1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:112] (version_check_finished)"
"2018-Apr-19 13:48:47.603 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-19 13:48:47.604 WARNING\tcore\tNo valid layouts found in the following directories: (\"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/../share\", \"/Users/ifreund/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.appContents/Resources\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/share\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:126] (DFInstance)"
"2018-Apr-19 13:48:47.604 DEBUG\tcore\truid = 501 , euid = 501 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:72] (DFInstanceOSX)"
"2018-Apr-19 13:48:47.615 INFO\tcore\tFound running copy, pid: 42485 path: \"/Users/ifreund/Documents/df_osx/./dwarfort.exe\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:169] (set_pid)"
"2018-Apr-19 13:48:47.618 ERROR\tcore\tcan't find running copy [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:177] (set_pid)"
"2018-Apr-19 13:48:47.618 WARNING\tcore\tlost connection to DF [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:467] (lost_df_connection)"
"2018-Apr-19 13:48:47.619 ERROR\tcore\t(\"Not Running\", \"Unable to locate a running copy of Dwarf Fortress, are you sure it's running?\", \"\", \"\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:489] (lost_df_connection)"
"2018-Apr-19 13:48:51.299 INFO\tcore\tBeginning shutdown [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:381] (closeEvent)"
"2018-Apr-19 13:48:51.299 INFO\tcore\tbeginning to write settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:358] (write_settings)"
"2018-Apr-19 13:48:51.301 INFO\tcore\tfinished writing settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:376] (write_settings)"
"2018-Apr-19 13:48:51.301 INFO\tcore\tClosing Dwarf Therapist normally [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:387] (closeEvent)"

Couldn't find any logs. If they should exist, let me know where to look

@ifreund
Copy link
Contributor

ifreund commented Apr 19, 2018

I am still confused by how these authorization rights work. What does the DFInstanceOSX::authorize method exactly do? Is it displaying a dialog for requesting root permissions and then setting the effective user id to 0 if it is accepted?

Yep, it pops up a dialog requesting an admin name and password every run. I'm pretty sure apple has some sort of keychain api that may make securely storing the authorization possible as well as cleaning up permissions issues. No idea how to use it though, will do some research.

Edit: I don't think keychain is what we want actually, it seems to be just for storing passwords and tokens. The api we want and I think are currently using to some extent is called Authorization Services which seems to have pretty decent documentation

@cvuchener
Copy link
Contributor

The warnings are known, but there is no solution yet. And I personally won't make major change to the OSX part.

ruid = 501 , euid = 0

That is the part I wanted to know: authorize changes the effective user id. Now you need to check if the rights can be reacquired after being dropped. There doesn't seem to be any POSIX way for getting the saved user id (since getresuid is linux only). Try reading DF memory and look for "seteuid(0) failed" errors.

3.9.1 only added new memory layouts, copy them manually or use git rebase, there should not be any conflict.

@ifreund
Copy link
Contributor

ifreund commented Apr 19, 2018

rebase gave add/add conflicts on 5 files :(
its gonna be a min

Edit:
Just copied over the 0.44.09 layout manually
Still didn't recognize that DF 0.44.09 was running

"2018-Apr-19 14:44:32.710 INFO\tcore\tDwarf Therapist \"39.3.0\" starting normally. [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:186] (setup_logging)"
"2018-Apr-19 14:44:32.710 INFO\tcore\tRuntime QT Version 5.10.1 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:187] (setup_logging)"
"2018-Apr-19 14:44:33.255 DEBUG\tcore\tsetting up connections for MainWindow [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:166] (MainWindow)"
"2018-Apr-19 14:44:33.731 INFO\tcore\tbeginning to read settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:213] (read_settings)"
"2018-Apr-19 14:44:33.746 INFO\tcore\tfinished reading settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:264] (read_settings)"
"2018-Apr-19 14:44:33.794 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-19 14:44:33.795 INFO\tcore\topening layout \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:105] (DFInstance)"
"2018-Apr-19 14:44:33.796 INFO\tcore\tadding valid layout \"v0.44.09 osx64\" checksum: \"0x5f5b1bf7\" SHA: \"990bc094fdf2bb66ce23b2b325db0632c0a9ae38\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:112] (DFInstance)"
"2018-Apr-19 14:44:33.797 INFO\tcore\topening layout \"/Users/ifreund/git-repos/Dwarf-Therapist/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:105] (DFInstance)"
"2018-Apr-19 14:44:33.798 INFO\tcore\tignoring already added layout, checksum: \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:115] (DFInstance)"

2018-04-19 14:44:33.799 DwarfTherapist[44414:9632725] Not authorized
"2018-Apr-19 14:44:37.991 INFO\tcore\tDwarf Therapist \"39.3.0\" starting normally. [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:186] (setup_logging)"
"2018-Apr-19 14:44:37.992 INFO\tcore\tRuntime QT Version 5.10.1 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:187] (setup_logging)"
"2018-Apr-19 14:44:38.530 DEBUG\tcore\tsetting up connections for MainWindow [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:166] (MainWindow)"
"2018-Apr-19 14:44:39.016 INFO\tcore\tbeginning to read settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:213] (read_settings)"
"2018-Apr-19 14:44:39.035 INFO\tcore\tfinished reading settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:264] (read_settings)"
"2018-Apr-19 14:44:39.088 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-19 14:44:39.088 INFO\tcore\topening layout \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:105] (DFInstance)"
"2018-Apr-19 14:44:39.090 INFO\tcore\tadding valid layout \"v0.44.09 osx64\" checksum: \"0x5f5b1bf7\" SHA: \"990bc094fdf2bb66ce23b2b325db0632c0a9ae38\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:112] (DFInstance)"
"2018-Apr-19 14:44:39.091 INFO\tcore\topening layout \"/Users/ifreund/git-repos/Dwarf-Therapist/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:105] (DFInstance)"
"2018-Apr-19 14:44:39.092 INFO\tcore\tignoring already added layout, checksum: \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:115] (DFInstance)"
"2018-Apr-19 14:44:39.098 DEBUG\tcore\truid = 501 , euid = 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:72] (DFInstanceOSX)"
"2018-Apr-19 14:44:39.109 INFO\tcore\tFound running copy, pid: 44386 path: \"/Users/ifreund/Documents/df_osx/./dwarfort.exe\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:169] (set_pid)"
"2018-Apr-19 14:44:39.112 ERROR\tcore\tcan't find running copy [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:177] (set_pid)"
"2018-Apr-19 14:44:39.113 WARNING\tcore\tlost connection to DF [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:467] (lost_df_connection)"
"2018-Apr-19 14:44:39.115 ERROR\tcore\t(\"Not Running\", \"Unable to locate a running copy of Dwarf Fortress, are you sure it's running?\", \"\", \"\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:489] (lost_df_connection)"
ifreundair:Dwarf-Therapist ifreund$ "2018-Apr-19 14:44:39.638 INFO\tcore\tNew version found \"39.3.1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:112] (version_check_finished)"
"2018-Apr-19 14:44:42.498 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-19 14:44:42.499 INFO\tcore\topening layout \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:105] (DFInstance)"
"2018-Apr-19 14:44:42.502 INFO\tcore\tadding valid layout \"v0.44.09 osx64\" checksum: \"0x5f5b1bf7\" SHA: \"990bc094fdf2bb66ce23b2b325db0632c0a9ae38\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:112] (DFInstance)"
"2018-Apr-19 14:44:42.503 INFO\tcore\topening layout \"/Users/ifreund/git-repos/Dwarf-Therapist/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:105] (DFInstance)"
"2018-Apr-19 14:44:42.506 INFO\tcore\tignoring already added layout, checksum: \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:115] (DFInstance)"
"2018-Apr-19 14:44:42.507 DEBUG\tcore\truid = 501 , euid = 501 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:72] (DFInstanceOSX)"
"2018-Apr-19 14:44:42.521 INFO\tcore\tFound running copy, pid: 44386 path: \"/Users/ifreund/Documents/df_osx/./dwarfort.exe\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:169] (set_pid)"
"2018-Apr-19 14:44:42.523 ERROR\tcore\tcan't find running copy [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:177] (set_pid)"
"2018-Apr-19 14:44:42.523 WARNING\tcore\tlost connection to DF [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:467] (lost_df_connection)"
"2018-Apr-19 14:44:42.524 ERROR\tcore\t(\"Not Running\", \"Unable to locate a running copy of Dwarf Fortress, are you sure it's running?\", \"\", \"\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:489] (lost_df_connection)"
"2018-Apr-19 14:44:44.884 INFO\tcore\tBeginning shutdown [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:381] (closeEvent)"
"2018-Apr-19 14:44:44.885 INFO\tcore\tbeginning to write settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:358] (write_settings)"
"2018-Apr-19 14:44:44.886 INFO\tcore\tfinished writing settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:376] (write_settings)"
"2018-Apr-19 14:44:44.886 INFO\tcore\tClosing Dwarf Therapist normally [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:387] (closeEvent)"

looks like it found it then lost it immediately?

@ifreund
Copy link
Contributor

ifreund commented Apr 20, 2018

This code should supposedly get the saved uid on macOS, haven't tested though. Taken from here

#include <unistd.h>
#include <stdio.h>
#include <sys/sysctl.h>

static int getsuid(uid_t* suid)
{
  int ctl[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
  struct kinfo_proc kip;
  size_t len = sizeof(kip);
  if (sysctl(ctl, 4, &kip, &len, 0, 0) < 0)
    return -1;
  *suid = kip.kp_eproc.e_pcred.p_svuid;
  return 0;
}

I will be busy pretty much all of tomorrow. Not quite sure what you meant about reading the DF memory but I should be available to test stuff again on Saturday.

@cvuchener
Copy link
Contributor

cvuchener commented Apr 20, 2018

I added seteuid(0) in ~~~find_running_copy~~~ (set_pid now, it was missing some return paths), hopefully it will be able to find DF instance now.

I also rebased on 39.3.1 (no conflict for me).

@ifreund
Copy link
Contributor

ifreund commented Apr 21, 2018

Hey, got done with some stuff earlier than I thought and had a chance to run this.
Looks like you made a little typo and had seteuid(new_euid) instead of seteuid(0)
I put in 0 and it found DF just fine!
Still saves the settings properly between runs too.

Output if you're interested (maybe helpful for tracking down the no equipment bug?):

"2018-Apr-20 19:28:13.246 INFO\tcore\tDwarf Therapist \"39.3.1\" starting normally. [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:186] (setup_logging)"
"2018-Apr-20 19:28:13.247 INFO\tcore\tRuntime QT Version 5.10.1 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:187] (setup_logging)"
"2018-Apr-20 19:28:13.867 DEBUG\tcore\tsetting up connections for MainWindow [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:166] (MainWindow)"
"2018-Apr-20 19:28:14.359 INFO\tcore\tbeginning to read settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:213] (read_settings)"
"2018-Apr-20 19:28:14.377 INFO\tcore\tfinished reading settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:264] (read_settings)"
"2018-Apr-20 19:28:14.451 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-20 19:28:14.452 WARNING\tcore\tNo valid layouts found in the following directories: (\"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/../share\", \"/Users/ifreund/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.appContents/Resources\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/share\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:126] (DFInstance)"

2018-04-20 19:28:14.452 DwarfTherapist[46731:10210713] Not authorized
"2018-Apr-20 19:28:20.322 INFO\tcore\tDwarf Therapist \"39.3.1\" starting normally. [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:186] (setup_logging)"
"2018-Apr-20 19:28:20.323 INFO\tcore\tRuntime QT Version 5.10.1 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:187] (setup_logging)"
"2018-Apr-20 19:28:20.872 DEBUG\tcore\tsetting up connections for MainWindow [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:166] (MainWindow)"
"2018-Apr-20 19:28:21.349 INFO\tcore\tbeginning to read settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:213] (read_settings)"
"2018-Apr-20 19:28:21.365 INFO\tcore\tfinished reading settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:264] (read_settings)"
"2018-Apr-20 19:28:21.415 INFO\tcore\tattempting connection to running DF game [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:406] (connect_to_df)"
"2018-Apr-20 19:28:21.415 WARNING\tcore\tNo valid layouts found in the following directories: (\"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/../share\", \"/Users/ifreund/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Library/Application Support/UDP Software/Dwarf Therapist\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.appContents/Resources\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build\", \"/Users/ifreund/git-repos/Dwarf-Therapist/build/share\") [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:126] (DFInstance)"
"2018-Apr-20 19:28:21.421 DEBUG\tcore\truid = 501 , euid = 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:72] (DFInstanceOSX)"
"2018-Apr-20 19:28:21.430 INFO\tcore\tFound running copy, pid: 46304 path: \"/Users/ifreund/Documents/df_osx/./dwarfort.exe\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstanceosx.mm:176] (set_pid)"
"2018-Apr-20 19:28:21.534 INFO\tcore\tSetting memory layout for DF checksum \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1086] (set_memory_layout)"
"2018-Apr-20 19:28:21.534 INFO\tcore\tCould not find layout for checksum \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1107] (get_memory_layout)"
"2018-Apr-20 19:28:21.534 INFO\tcore\tChecking for layout for checksum:  \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:133] (check_layouts)"
"2018-Apr-20 19:28:21.933 DEBUG\tcore\tdownloading layout \"v0.42.01_osx.ini\" SHA: \"9165a43a63cff5e222c323768957f2181752abf9\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.934 DEBUG\tcore\tdownloading layout \"v0.42.02_osx.ini\" SHA: \"bb40e7d27624d665c5fcec3a265eded4875cbb62\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.934 DEBUG\tcore\tdownloading layout \"v0.42.03_osx.ini\" SHA: \"0dac77cb52235314849c858b05227f11f3f6c3b0\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.935 DEBUG\tcore\tdownloading layout \"v0.42.04_osx.ini\" SHA: \"f84b73666780df10a12cce3002c6d01013b1b2f7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.935 DEBUG\tcore\tdownloading layout \"v0.42.05_osx.ini\" SHA: \"94c64cebae4eceee2d85651670c234188113bd94\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.936 DEBUG\tcore\tdownloading layout \"v0.42.06_osx.ini\" SHA: \"9d7afd1e47534c2edd0c31ea253c9ddfb552c841\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.936 DEBUG\tcore\tdownloading layout \"v0.43.01_osx.ini\" SHA: \"b3d13e57080ebed027013930b0134ed6c980eec2\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.937 DEBUG\tcore\tdownloading layout \"v0.43.02_osx.ini\" SHA: \"0403a7bcdff4f91698eeb347c7f00d52578b4f40\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.938 DEBUG\tcore\tdownloading layout \"v0.43.03_osx.ini\" SHA: \"df13abfe748b87b33ed4b9f2d02a6ba874c4b7cf\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.938 DEBUG\tcore\tdownloading layout \"v0.43.05_osx32.ini\" SHA: \"11d9ac7b0b9029e664308b9afa471b3fa3d56d39\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.939 DEBUG\tcore\tdownloading layout \"v0.43.05_osx64.ini\" SHA: \"96989f42db5e622ad1b1d68dcfb75bcf6862fbf6\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.939 DEBUG\tcore\tdownloading layout \"v0.44.02_osx32.ini\" SHA: \"bf50712a36128b0dd9c9b6288cff0c3887fe2def\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.940 DEBUG\tcore\tdownloading layout \"v0.44.02_osx64.ini\" SHA: \"51d36feab9ddbe3a3e12579d23f3ae994e766236\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.940 DEBUG\tcore\tdownloading layout \"v0.44.03_osx32.ini\" SHA: \"9c2af0e1a228f00c223c44e4cd2e923d65d19eb1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.940 DEBUG\tcore\tdownloading layout \"v0.44.03_osx64.ini\" SHA: \"b55193c782b7997122e9906899a612fc395103d7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.941 DEBUG\tcore\tdownloading layout \"v0.44.04_osx32.ini\" SHA: \"579446e040890ae63e58da4447344513f618db29\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.941 DEBUG\tcore\tdownloading layout \"v0.44.04_osx64.ini\" SHA: \"237f80b83cb348513d0d61b3d61866e29588720d\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.942 DEBUG\tcore\tdownloading layout \"v0.44.05_osx32.ini\" SHA: \"38b536f28325b2d47826b8986286f6d49c0ec51d\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.942 DEBUG\tcore\tdownloading layout \"v0.44.05_osx64.ini\" SHA: \"5bd5a05b0f7ac6b3621b9918d9c7306fc4afed7b\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.943 DEBUG\tcore\tdownloading layout \"v0.44.06_osx32.ini\" SHA: \"42b8975b336c98dac575c507a4221a24d32228a1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.943 DEBUG\tcore\tdownloading layout \"v0.44.06_osx64.ini\" SHA: \"ea2e1909d3ab0895dfe71707e33bd4e5c7ad03a7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.943 DEBUG\tcore\tdownloading layout \"v0.44.07_osx32.ini\" SHA: \"45512169ab4ebb4a1dee06e4d362eadd948a6cd7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.944 DEBUG\tcore\tdownloading layout \"v0.44.07_osx64.ini\" SHA: \"65d418b3e8aa9db8783a9c86d58318cc3f208586\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.944 DEBUG\tcore\tdownloading layout \"v0.44.08_osx32.ini\" SHA: \"e532757e868e2ae6628b71bf7dc432713c057ae9\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.944 DEBUG\tcore\tdownloading layout \"v0.44.08_osx64.ini\" SHA: \"19100b5810106f60cdc6883e3fb6dda6e7a33d81\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.945 DEBUG\tcore\tdownloading layout \"v0.44.09_osx32.ini\" SHA: \"766fcd1a3cdf3bbd85fd6bcb43f3cf85f104476a\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:21.945 DEBUG\tcore\tdownloading layout \"v0.44.09_osx64.ini\" SHA: \"990bc094fdf2bb66ce23b2b325db0632c0a9ae38\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/updater.cpp:207] (find_layout_urls)"
"2018-Apr-20 19:28:22.488 INFO\tcore\tCould not find layout for checksum \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1107] (get_memory_layout)"
"2018-Apr-20 19:28:22.489 INFO\tcore\tCreating new layout file: \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1141] (add_new_layout)"
"2018-Apr-20 19:28:22.492 INFO\tcore\tadding valid layout \"v0.44.09 osx64\" \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1157] (add_new_layout)"
"2018-Apr-20 19:28:23.274 INFO\tcore\tSetting memory layout for DF checksum \"0x5f5b1bf7\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1086] (set_memory_layout)"
"2018-Apr-20 19:28:23.275 INFO\tcore\tDetected Dwarf Fortress version \"v0.44.09 osx64\" using MemoryLayout from \"/Users/ifreund/git-repos/Dwarf-Therapist/build/DwarfTherapist.app/Contents/MacOS/share/memory_layouts/osx/v0.44.09_osx64.ini\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1091] (set_memory_layout)"
"2018-Apr-20 19:28:23.276 INFO\tcore\tConnection to DF version \"v0.44.09 osx64\" established. [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:430] (connect_to_df)"
"2018-Apr-20 19:28:23.278 DEBUG\tcore\tLoading language translation tables [/Users/ifreund/git-repos/Dwarf-Therapist/src/languages.cpp:59] (load_data)"
"2018-Apr-20 19:28:23.278 DEBUG\tcore\tLoading generic strings from \"0x0000000101cc9ff8\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/languages.cpp:73] (load_data)"
"2018-Apr-20 19:28:23.279 DEBUG\tcore\tgeneric words 2195 [/Users/ifreund/git-repos/Dwarf-Therapist/src/languages.cpp:75] (load_data)"
"2018-Apr-20 19:28:23.476 DEBUG\tcore\treading material templates [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:639] (load_main_vectors)"
"2018-Apr-20 19:28:23.481 DEBUG\tcore\treading syndromes [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:646] (load_main_vectors)"
"2018-Apr-20 19:28:23.481 DEBUG\tcore\treading item and subitem types [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:650] (load_main_vectors)"
"2018-Apr-20 19:28:23.482 DEBUG\tcore\treading colors, shapes, poems, music and dances [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:666] (load_main_vectors)"
"2018-Apr-20 19:28:23.483 DEBUG\tcore\treading base materials [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:673] (load_main_vectors)"
"2018-Apr-20 19:28:23.501 DEBUG\tcore\treading inorganics [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:686] (load_main_vectors)"
"2018-Apr-20 19:28:23.759 DEBUG\tcore\treading plants [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:697] (load_main_vectors)"
"2018-Apr-20 19:28:23.862 DEBUG\tcore\tdwarf race index \"0x0000000101ba2034\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:314] (load_game_data)"
"2018-Apr-20 19:28:23.862 DEBUG\tcore\tdwarf race: 572 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:317] (load_game_data)"
"2018-Apr-20 19:28:23.863 DEBUG\tcore\treading races and castes [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:763] (load_races_castes)"
"2018-Apr-20 19:28:24.243 DEBUG\tcore\treading item types [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:721] (load_item_defs)"
"2018-Apr-20 19:28:24.244 DEBUG\tcore\t   reading item types for type 26 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.247 DEBUG\tcore\t   reading item types for type 59 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.251 DEBUG\tcore\t   reading item types for type 25 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.256 DEBUG\tcore\t   reading item types for type 29 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.258 DEBUG\tcore\t   reading item types for type 28 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.262 DEBUG\tcore\t   reading item types for type 24 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.272 DEBUG\tcore\t   reading item types for type 38 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.273 DEBUG\tcore\t   reading item types for type 67 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.274 DEBUG\tcore\t   reading item types for type 27 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.274 DEBUG\tcore\t   reading item types for type 85 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.288 DEBUG\tcore\t   reading item types for type 13 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:731] (load_item_defs)"
"2018-Apr-20 19:28:24.292 DEBUG\tcore\treading fortress name [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:839] (load_fortress_name)"
"2018-Apr-20 19:28:24.292 DEBUG\tcore\t   reading sites... [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:844] (load_fortress_name)"
"2018-Apr-20 19:28:24.293 DEBUG\tcore\t   found player fortress with name \"Rag?rith\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:851] (load_fortress_name)"
"2018-Apr-20 19:28:24.294 INFO\tcore\tLoading built-in default gridviews [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:134] (reload_views)"
"2018-Apr-20 19:28:24.298 DEBUG\tcore\tgridview \"Other Skills\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.300 DEBUG\tcore\tgridview \"Labors Compact\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.302 DEBUG\tcore\tgridview \"Labors Full\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.303 DEBUG\tcore\tgridview \"Military\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.304 DEBUG\tcore\tgridview \"Attributes\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.304 DEBUG\tcore\tgridview \"Animals\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.306 DEBUG\tcore\tgridview \"Roles\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.307 DEBUG\tcore\tgridview \"Military-Alt.\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.309 DEBUG\tcore\tgridview \"Traits\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.310 DEBUG\tcore\tgridview \"Social-Alt.\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.311 DEBUG\tcore\tgridview \"Health\" added [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:188] (load_views)"
"2018-Apr-20 19:28:24.311 INFO\tcore\tLoaded 12 views from disk [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:174] (reload_views)"
"2018-Apr-20 19:28:24.317 INFO\tcore\tgroup_by now set to 0  for view  \"Labors Full\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.324 INFO\tcore\tgroup_by now set to 0  for view  \"Military\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.325 DEBUG\tcore\tnot sorting view \"Military\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:529] (setCurrentIndex)"
"2018-Apr-20 19:28:24.332 INFO\tcore\tgroup_by now set to 0  for view  \"Other Skills\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.332 DEBUG\tcore\tnot sorting view \"Other Skills\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:529] (setCurrentIndex)"
"2018-Apr-20 19:28:24.339 INFO\tcore\tgroup_by now set to 0  for view  \"Attributes\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.340 DEBUG\tcore\tnot sorting view \"Attributes\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:529] (setCurrentIndex)"
"2018-Apr-20 19:28:24.346 INFO\tcore\tgroup_by now set to 0  for view  \"Roles\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.346 DEBUG\tcore\tnot sorting view \"Roles\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:529] (setCurrentIndex)"
"2018-Apr-20 19:28:24.353 INFO\tcore\tgroup_by now set to 0  for view  \"Animals\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.353 DEBUG\tcore\tnot sorting view \"Animals\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:529] (setCurrentIndex)"
"2018-Apr-20 19:28:24.354 INFO\tcore\tgroup_by now set to 0  for view  \"Labors Full\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.354 DEBUG\tcore\tnot sorting view \"Labors Full\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:529] (setCurrentIndex)"
"2018-Apr-20 19:28:24.355 INFO\tcore\t\"redrew views in 43ms\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:322] (draw_views)"
"2018-Apr-20 19:28:24.356 DEBUG\tcore\tloading current year from \"0x0000000101b9f88c\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:784] (refresh_data)"
"2018-Apr-20 19:28:24.356 INFO\tcore\tcurrent year: 5 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:789] (refresh_data)"
"2018-Apr-20 19:28:24.356 DEBUG\tcore\tloading activities [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:1259] (load_activities)"
"2018-Apr-20 19:28:24.356 DEBUG\tcore\tloading fortress entity [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:826] (load_fortress)"
"2018-Apr-20 19:28:24.358 DEBUG\tcore\tloading squads [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:858] (load_squads)"
"2018-Apr-20 19:28:24.358 DEBUG\tcore\tloading squads from  \"0x0000000101cc32a0\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:873] (load_squads)"
"2018-Apr-20 19:28:24.359 INFO\tcore\tFOUND 0 squads [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:880] (load_squads)"
"2018-Apr-20 19:28:24.359 DEBUG\tcore\tloading items [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:800] (load_items)"
"2018-Apr-20 19:28:24.361 DEBUG\tcore\tloading creatures from  \"0x0000000101bc57c0\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:370] (load_dwarves)"
"2018-Apr-20 19:28:24.361 DEBUG\tcore\tcivilization id: 11 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:376] (load_dwarves)"
"2018-Apr-20 19:28:24.361 INFO\tcore\tusing active units [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:956] (get_creatures)"
"2018-Apr-20 19:28:24.361 INFO\tcore\tno active units with our civ (reclaim), using full unit list [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:962] (get_creatures)"
"2018-Apr-20 19:28:24.379 DEBUG\tcore\treading profession for \"Momuz Luslemfikod\" 0 \"Miner\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.383 DEBUG\tcore\treading inventory for \"Momuz Luslemfikod\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.388 DEBUG\tcore\t  total inventory items found: 15 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.388 INFO\tcore\t\"FOUND Dwarf (0x000000011c781600) name:Momuz Luslemfikod id:97 histfig_id:151\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.389 DEBUG\tcore\treading profession for \"Tun Asteshmemad\" 5 \"Stoneworker\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.392 DEBUG\tcore\treading inventory for \"Tun Asteshmemad\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.396 DEBUG\tcore\t  total inventory items found: 14 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.396 INFO\tcore\t\"FOUND Dwarf (0x000000011f160000) name:Tun Asteshmemad id:98 histfig_id:152\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.398 DEBUG\tcore\treading profession for \"Ducim Nishalis\" 20 \"Jeweler\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.401 DEBUG\tcore\treading inventory for \"Ducim Nishalis\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.405 DEBUG\tcore\t  total inventory items found: 14 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.405 INFO\tcore\t\"FOUND Dwarf (0x000000011f161400) name:Ducim Nishalis id:99 histfig_id:153\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.407 DEBUG\tcore\treading profession for \"Monom Shinrig?th\" 1 \"Woodworker\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.409 DEBUG\tcore\treading inventory for \"Monom Shinrig?th\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.413 DEBUG\tcore\t  total inventory items found: 14 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.413 INFO\tcore\t\"FOUND Dwarf (0x000000011f162800) name:Monom Shinrig?th id:100 histfig_id:154\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.415 DEBUG\tcore\treading profession for \"Minkot Kor?nul\" 38 \"Fish Cleaner\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.419 DEBUG\tcore\treading inventory for \"Minkot Kor?nul\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.422 DEBUG\tcore\t  total inventory items found: 14 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.423 INFO\tcore\t\"FOUND Dwarf (0x000000011f163c00) name:Minkot Kor?nul id:101 histfig_id:155\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.424 DEBUG\tcore\treading profession for \"Ilral Nilzulban\" 4 \"Woodcutter\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.426 DEBUG\tcore\treading inventory for \"Ilral Nilzulban\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.430 DEBUG\tcore\t  total inventory items found: 15 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.430 INFO\tcore\t\"FOUND Dwarf (0x000000011f165000) name:Ilral Nilzulban id:102 histfig_id:156\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.432 DEBUG\tcore\treading profession for \"Edzul Ingishsuvas\" 36 \"Fisherman\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.434 DEBUG\tcore\treading inventory for \"Edzul Ingishsuvas\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.438 DEBUG\tcore\t  total inventory items found: 14 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.438 INFO\tcore\t\"FOUND Dwarf (0x000000011f19e400) name:Edzul Ingishsuvas id:103 histfig_id:157\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.440 DEBUG\tcore\treading profession for \"Dog\" 102 \"Peasant\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.441 DEBUG\tcore\treading inventory for \"Dog\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.441 DEBUG\tcore\t  total inventory items found: 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.441 INFO\tcore\t\"FOUND Dog (0x000000011f19f800) name:Dog id:104 histfig_id:-1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.443 DEBUG\tcore\treading profession for \"Dog\" 102 \"Peasant\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.443 DEBUG\tcore\treading inventory for \"Dog\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.443 DEBUG\tcore\t  total inventory items found: 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.443 INFO\tcore\t\"FOUND Dog (0x000000011f1a0c00) name:Dog id:105 histfig_id:-1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.445 DEBUG\tcore\treading profession for \"Cat\" 102 \"Peasant\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.446 DEBUG\tcore\treading inventory for \"Cat\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.446 DEBUG\tcore\t  total inventory items found: 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.446 INFO\tcore\t\"FOUND Cat (0x000000011f1a2000) name:Cat id:106 histfig_id:-1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.448 DEBUG\tcore\treading profession for \"Cat\" 102 \"Peasant\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.448 DEBUG\tcore\treading inventory for \"Cat\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.448 DEBUG\tcore\t  total inventory items found: 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.449 INFO\tcore\t\"FOUND Cat (0x000000011f1a3400) name:Cat id:107 histfig_id:-1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.450 DEBUG\tcore\treading profession for \"Yak\" 102 \"Peasant\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.451 DEBUG\tcore\treading inventory for \"Yak\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.451 DEBUG\tcore\t  total inventory items found: 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.452 INFO\tcore\t\"FOUND Yak (0x000000011f1a4800) name:Yak Bull id:108 histfig_id:-1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.453 DEBUG\tcore\treading profession for \"Yak\" 102 \"Peasant\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:834] (read_profession)"
"2018-Apr-20 19:28:24.455 DEBUG\tcore\treading inventory for \"Yak\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1491] (read_inventory)"
"2018-Apr-20 19:28:24.455 DEBUG\tcore\t  total inventory items found: 0 [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:1577] (read_inventory)"
"2018-Apr-20 19:28:24.455 INFO\tcore\t\"FOUND Yak (0x000000011f1a5c00) name:Yak Cow id:109 histfig_id:-1\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:309] (read_data)"
"2018-Apr-20 19:28:24.456 DEBUG\tcore\t\"IGNORING Magma Crab name:Magma Crab id:110 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.457 DEBUG\tcore\t\"IGNORING Magma Crab name:Magma Crab id:111 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.459 DEBUG\tcore\t\"IGNORING Magma Crab name:Magma Crab id:112 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.460 DEBUG\tcore\t\"IGNORING Magma Crab name:Magma Crab id:113 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.461 DEBUG\tcore\t\"IGNORING Magma Crab name:Magma Crab id:114 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.462 DEBUG\tcore\t\"IGNORING Deer name:Deer id:115 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.463 DEBUG\tcore\t\"IGNORING Deer name:Deer id:116 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.464 DEBUG\tcore\t\"IGNORING Deer name:Deer id:117 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.465 DEBUG\tcore\t\"IGNORING Deer name:Deer id:118 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.466 DEBUG\tcore\t\"IGNORING Giant Bat name:Giant Bat id:119 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.467 DEBUG\tcore\t\"IGNORING Troglodyte name:Troglodyte id:120 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.468 DEBUG\tcore\t\"IGNORING Troglodyte name:Troglodyte id:121 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.470 DEBUG\tcore\t\"IGNORING Troglodyte name:Troglodyte id:122 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.471 DEBUG\tcore\t\"IGNORING Troglodyte name:Troglodyte id:123 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.472 DEBUG\tcore\t\"IGNORING Troglodyte name:Troglodyte id:124 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.473 DEBUG\tcore\t\"IGNORING Troglodyte name:Troglodyte id:125 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.474 DEBUG\tcore\t\"IGNORING Voracious Cave Crawler name:Voracious Cave Crawler id:126 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.476 DEBUG\tcore\t\"IGNORING Sard Fiend name:Sard Fiend id:127 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.477 DEBUG\tcore\t\"IGNORING Sard Fiend name:Sard Fiend id:128 reason:doesn't belong to our civilization\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarf.cpp:382] (set_validation)"
"2018-Apr-20 19:28:24.478 INFO\tcore\tread 13 units in 100 ms [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:404] (load_dwarves)"
"2018-Apr-20 19:28:24.496 INFO\tcore\tcalculated roles in 18 ms [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:416] (load_dwarves)"
"2018-Apr-20 19:28:24.497 INFO\tcore\tloaded population data in 1 ms [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:421] (load_dwarves)"
"2018-Apr-20 19:28:24.523 INFO\tcore\tfound 13 units out of 32 creatures [/Users/ifreund/git-repos/Dwarf-Therapist/src/dfinstance.cpp:435] (load_dwarves)"
"2018-Apr-20 19:28:24.589 INFO\tcore\tgroup_by now set to 0  for view  \"Labors Full\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:789] (set_group_by)"
"2018-Apr-20 19:28:24.642 INFO\tcore\tloaded rows for \"Labors Full\" 53 ms [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarfmodel.cpp:795] (set_group_by)"
"2018-Apr-20 19:28:24.643 DEBUG\tcore\tnot sorting view \"Labors Full\" [/Users/ifreund/git-repos/Dwarf-Therapist/src/viewmanager.cpp:529] (setCurrentIndex)"
"2018-Apr-20 19:28:38.617 INFO\tcore\tcompleted read in 14262 ms [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:626] (read_dwarves)"
"2018-Apr-20 19:29:25.435 INFO\tcore\tbeginning to read settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:213] (read_settings)"
"2018-Apr-20 19:29:25.436 INFO\tcore\tfinished reading settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/dwarftherapist.cpp:264] (read_settings)"
"2018-Apr-20 19:29:26.847 INFO\tcore\tBeginning shutdown [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:381] (closeEvent)"
"2018-Apr-20 19:29:26.848 INFO\tcore\tbeginning to write settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:358] (write_settings)"
"2018-Apr-20 19:29:26.849 INFO\tcore\tfinished writing settings [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:376] (write_settings)"
"2018-Apr-20 19:29:26.850 INFO\tcore\tClosing Dwarf Therapist normally [/Users/ifreund/git-repos/Dwarf-Therapist/src/mainwindow.cpp:387] (closeEvent)"

@cvuchener
Copy link
Contributor

It should be fixed by #82, please re-open if it is still happening.

@cvuchener
Copy link
Contributor

According to falcn, this is not fixed for the first run.

@cvuchener cvuchener reopened this Jan 7, 2019
@cvuchener cvuchener added the osx label Jan 7, 2019
@falcn
Copy link

falcn commented Jan 7, 2019

While we are here, why we save Dwarf Therapist.ini to the ~/.config/Dwarf Therapist and the rest of the app data to the ~/Library/Application Support/Dwarf Therapist?

@cvuchener
Copy link
Contributor

Standard location for config files is ~/Library/Preferences, but only when using native format (CFPreferences). DT stores its config in ini format for portability, and they cannot be stored at the same place. Qt decided to follow XDG specification and uses ~/.config (or XDG_CONFIG_HOME) like Linux.

Reading the documentation, I guess you could say that storing ini configuration files in "Application Support" is okay, like Windows with AppData.

Contains all app-specific data and support files. These are the files that your app creates and manages on behalf of the user and can include files that contain user data.

By convention, all of these items should be put in a subdirectory whose name matches the bundle identifier of the app. For example, if your app is named MyApp and has the bundle identifier com.example.MyApp, you would put your app’s user-specific data files and resources in the ~/Library/Application Support/com.example.MyApp/ directory. Your app is responsible for creating this directory as needed.

Resources required by the app to run must be placed inside the app bundle itself.

But DT is only using Qt's defaults. Maybe it is a Qt bug. By the way, ConfigLocation and AppConfigLocation use ~/Library/Preferences/ although the apple documentation says "You should never create files in this directory yourself. To get or set preference values, you should always use the NSUserDefaults class or an equivalent system-provided interface."

@falcn
Copy link

falcn commented Jan 8, 2019

you could say that storing ini configuration files in "Application Support" is okay, like Windows with AppData.

As a long time Mac user, I'm expecting to find all application settings in ~/Library/Application Support/Appname. I'm not surprised that cross-platform apps not following guidelines and use dot folders in user home directory, happens all the time, but it just weird that DT is saving its ini files in two separate folders. I understand why it happens, but can we consolidate them in one place, preferably ~/Library/Application Support/Dwarf Therapist?

@cvuchener
Copy link
Contributor

The location can be overridden with QSettings::setPath, but you should consider discussing the default locations with Qt devs.

Or, as a workaround, add export XDG_CONFIG_HOME="$HOME/Library/Application Support" in your environment and you won't even have to recompile DT.

@falcn
Copy link

falcn commented Jan 9, 2019

XDG_CONFIG_HOME

Since DT don't have a shell script that I can use to control env for people who run it from a pack, I tried to be a smartass and added the following to the Info.plist as described here

	<key>LSEnvironment</key>
	<dict>
	     <key>XDG_CONFIG_HOME</key>
	     <string>Library/Application Support</string>
	</dict>

And it worked, now everything is neatly stored in one place. Thank you! Maybe you should push this change to the upstream?

Anyway, sorry for the sidetrack, back to the topic.
On the very first run, DT creates Dwarf Therapist.ini owned by root. This can be easily fixed by creating config before asking for password. There is no harm in that.

@cvuchener
Copy link
Contributor

It is hard to control when the QSettings file is saved. If it keeps the current user after the first write, try adding m_user_settings->sync();
after this line

m_user_settings = StandardPaths::settings();

This should force a write early enough. Assuming it creates the file even when the QSettings object is empty.

@falcn
Copy link

falcn commented Jan 9, 2019

Unfortunately I can't build, I can only test.
I was wrong, pre-creating empty file doesn't fix it, the problem is elsewhere.

  1. DT started, no config exists
  2. DT creates config owned by user, and populates it with default data
  3. DT asks for password. file is owned by user (DT has no other privs yet)
  4. Password entered, DT renders empty window. file is owned by user
  5. Message "Downloading memory layout" is shown. file is owned by user
  6. Progress bar fills to 95%. file is owned by user
  7. progress bar freezes for a couple of seconds. file is owned by user
  8. file ownership changes, now file is owned by root. At the same time, following data are added to the default config created on step 2:
3a4,12
> [gui_options]
> Animals_group_by=0
> Attributes_group_by=0
> Labors%20Full_group_by=0
> Military_group_by=0
> Other%20Skills_group_by=0
> Roles_group_by=0
> tab_order=Labors Full, Military, Other Skills, Attributes, Roles, Animals
  1. after .5 seconds progressbar gets filled to 100% and disappears.

At this step, if file stays owned by root, DT can't write to it anymore.
If file ownership gets externally changed back to user, DT no ownership changes to root ever occur anymore.
I hope it narrows down the search for problematic write.

@falcn
Copy link

falcn commented Jan 9, 2019

Just wanted to add, I think it's important:

If on step 2-3 file permissions are changed from 644 to 666, on step 8 file ownership gets very briefly changed to root and then returned back to user in 0.1 seconds or so.

@falcn
Copy link

falcn commented Jan 9, 2019

If on step 9 file gets deleted, it gets re-created on app exit with correct ownership, and it keeps it between runs. The write that happens at step 8 (the one that adds [gui_options] block) is the only one that is problematic. If [gui_options] are already there, file keeps user ownership.

Nope, if file loses 666 permissions, it gets root ownership here

on step 8 file ownership gets very briefly changed to root and then returned back to user in 0.1 seconds or so

...and never gets returned to user, because code that does that doesn't work on root-owned files.
So there are two problems here

  1. some code resets file ownership to root at step 8
  2. code that changes file ownership back to user can only do so if file has permissions set to 666.

@cvuchener
Copy link
Contributor

If I understand correctly, QSettings writes a new temporary file then rename it to replace the old one. This is done to avoid partial writes if something wrong happens when saving the file. This may be reason the permission are changed. This behavior can be changed by calling setAtomicSyncRequired.

@lethosor
Copy link
Contributor

Yeah, setuid is per-process, not per-thread - see notes at http://man7.org/linux/man-pages/man2/setuid.2.html

@joatmon3
Copy link

joatmon3 commented Aug 5, 2019

In case anyone else comes across this thread looking for how to make Dwarf Therapist save settings, the file I had to grant write access to was ~/.config/Dwarf Therapist/Dwarf Therapist.ini, not ~/.config/UDP Software/Dwarf Therapist.ini. Hopefully this helps someone avoid an hour and a half of messing around. :-D

@cvuchener
Copy link
Contributor

As part of #167, I made some changes that may help with this issue. Logs were also created as root. With 73b5c8f DT will drop root privileges earlier (as soon as the QApplication object is created, for some reason I cannot do it in main). I still don't control when settings are saved, but DT will spend less time as root, so it should be rarer.

@Barenhvrd
Copy link

Barenhvrd commented Aug 22, 2019

Hi! running the latest DT, still doesn't save between sessions and is now crashing at every startups. sometimes opens (mac os) and crashes every time I am trying to quit it.
Are there files located elsewhere than the /applications? I'd like to remove every bit of DT and try again

@cvuchener
Copy link
Contributor

now crashing at every startups.

Any crash log?

Are there files located elsewhere than the /applications? I'd like to remove every bit of DT and try again

Config file is in ~/.config/Dwarf Therapist. Old logs were in a log directory in the current working directory (next to the .dmg file?), new logs are in ~/Library/Logs/Dwarf Therapist/. Some data files may be in ~/Library/Application Support/Dwarf Therapist. That should be all.

@Barenhvrd
Copy link

Barenhvrd commented Aug 22, 2019

thanks for the quick answer @cvuchener

crash log on open (right after I enter my password): https://pastebin.com/qZtnhraf
crash log on close: https://pastebin.com/SAd9hf56

Also deleted all files in folders you listed, the crash logs are from a clean new install

Still not loading my settings when I managed to start DT

Attached DT logs from the log folder (there are 4 logs in the folder)

dwarftherapist.log

@cvuchener
Copy link
Contributor

I can reproduce the crash with the release build, but not when I recompile myself. I found something wrong with RoleModel, but I am not sure it is the cause of the crash.

I cannot manage to use valgrind on the macOS version I have access too, so it is hard to debug.

@cvuchener
Copy link
Contributor

Does this version solves the crash for you?

@Barenhvrd
Copy link

This version looks like it is not crashing! (just once in my tests, but that one crash can be discarded). On the other hand it is not saving the settings yet

@cvuchener
Copy link
Contributor

I guess it is the usual issue about the ownership of ~/.config/Dwarf Therapist/Dwarf Therapist.ini. Since I don't think I can really fix this one, let's try to make the workaround automatic. Try this release. It should try to chown to config file when quitting (assuming it does not crash before).

@Barenhvrd
Copy link

Barenhvrd commented Aug 27, 2019

This release crashes upon exit: https://pastebin.com/pcJUeXBN and therefore doesn't save

@cvuchener
Copy link
Contributor

This one should work better.

@Barenhvrd
Copy link

sadly crashes right after entering the password https://pastebin.com/paUu0dqf

@cvuchener
Copy link
Contributor

Sorry I cannot reproduce this. From the backtrace it is either a Qt bug, or a memory corruption happening earlier that I cannot find by just looking at the crash log.

@Barenhvrd
Copy link

ouch, anything I can do to help?

@cvuchener
Copy link
Contributor

I am not an expert on macOS debugging. Valgrind can often give good information on memory corruption, but it is not available for recent versions of macOS. Maybe there is another tool that can help, but I don't know it.

@jecowa
Copy link

jecowa commented Mar 10, 2020

Currently to use the Lazy Mac Pack requires users to run a shell script to make PyLNP, DFHack, nearly every utility, and some libraries work properly. I'm dealing with the settings-not-saving issue by having the shell script "touch" the settings file. In this way before Dwarf Therapist is run, the settings file is already created with permissions that allow settings to be saved. Probably doesn't help, but just in case:

mkdir ~/.config/
mkdir ~/.config/Dwarf\ Therapist/
touch ~/.config/Dwarf\ Therapist/Dwarf\ Therapist.ini

Upside is that it doesn't require admin password for sudo. Downside is that it doesn't fix the problem if the settings file already exists with bad permissions. Imo, the "touch" command should create the parent directories if they don't already exist, but unfortunately, it doesn't.

@lethosor
Copy link
Contributor

mkdir -p will create intermediate directories as needed (not files, though).
If you've determined that the issue here is incorrect permissions/ownership, I suspect DT should be able to fix that by creating the file (if needed) before running as root.

@cvuchener
Copy link
Contributor

cvuchener commented Mar 21, 2020

I suspect DT should be able to fix that by creating the file (if needed) before running as root.

That was what I attempted to do in e1fcd55 but it broke DT for unknown reasons (#177) so it was reverted (5140ef5).

it doesn't fix the problem if the settings file already exists with bad permissions.

There is a trick I know on Linux (but I don't know if it is portable) for changing ownership of a file you don't own but can read in a directory you own. You can delete files in directories you own, so make a copy then replace the original.

$ sudo touch file
$ ls -l file
-rw-r--r--. 1 root root 0 Mar 21 10:50 file
$ ls -ld .
drwxrwxr-x. 2 clement clement 4096 Mar 21 10:50 .
$ chown clement:clement file
chown: changing ownership of 'file': Operation not permitted
$ cp file{,.bak} && mv -f file{.bak,}
$ ls -l file
-rw-r--r--. 1 clement clement 0 Mar 21 10:50 file

@lethosor
Copy link
Contributor

Instead of dropping permissions as e1fcd55 does, I was suggesting creating the file before escalating to root (e.g. in DFInstanceOSX()). That might be trickier, though - I'm not very familiar with the codebase here.

@SomethingWrong
Copy link

SomethingWrong commented May 13, 2020

Whoever wonders about a fix, right now it's
sudo chmod 666 ~/.config/Dwarf\ Therapist/Dwarf\ Therapist.ini

@falcn
Copy link

falcn commented May 13, 2020

I see you are still messing with ~/.config/
Just a reminder that we can have all config files stored in one place on MacOS by adding this to the Info.plist

	<key>LSEnvironment</key>
	<dict>
	     <key>XDG_CONFIG_HOME</key>
	     <string>Library/Application Support</string>
	</dict>

@SomethingWrong
Copy link

@falcn oh, I have missed that part. Thanks for point out!

@Mr12012912
Copy link

ok, I just read all of this and I cant understand what I am supposed to do to fix this issue could someone explain.

@cvuchener
Copy link
Contributor

Try changing the permissions (chmod) of ~/.config/Dwarf Therapist/Dwarf Therapist.ini. Use SomethingWrong command:

sudo chmod 666 ~/.config/Dwarf\ Therapist/Dwarf\ Therapist.ini

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

Successfully merging a pull request may close this issue.

10 participants