pam icon indicating copy to clipboard operation
pam copied to clipboard

Expose PamEnvList and PamEnvIter API

Open regiontog opened this issue 5 years ago • 6 comments

regiontog avatar May 27 '19 17:05 regiontog

I merged your other PR first, so this needs a rebase, but after that I'll merge this. If you could also write a CHANGELOG entry, that would be awesome, if not I'll do it after merging ;)

1wilkens avatar May 28 '19 14:05 1wilkens

I tested the null check on the first indirection and I unfortunately the assertion failed immediately.

thread 'main' panicked at 'assertion failed: unsafe { !(*env_ptr).is_null() }', /home/alan/dev/regiontog/pam/src/env.rs:52:13

I know it worked with the check on only the second indirection, but I don't understand why. I logged the pointers as the iterator was ran and it seems like the variables stop after the inner pointer is null:

env ptr: 0x55eded603450 deref env ptr: 0x55eded604f40 env ptr: 0x55eded603458 deref env ptr: 0x55eded604e70 env ptr: 0x55eded603460 deref env ptr: 0x55eded606590 env ptr: 0x55eded603468 deref env ptr: 0x55eded6049e0 env ptr: 0x55eded603470 deref env ptr: 0x55eded603550 env ptr: 0x55eded603478 deref env ptr: 0x55eded603520 env ptr: 0x55eded603480 deref env ptr: 0x55eded6034f0 env ptr: 0x55eded603488 deref env ptr: 0x55eded600010 env ptr: 0x55eded603490 deref env ptr: 0x55eded6034c0 env ptr: 0x55eded603498 deref env ptr: 0x55eded603390 env ptr: 0x55eded6034a0 deref env ptr: 0x55eded603300 env ptr: 0x55eded6034a8 deref env ptr: 0x55eded6053e0 env ptr: 0x55eded6034b0 deref env ptr: 0x0 env ptr: 0x55eded6034b8 deref env ptr: 0x31 segmentation fault (core dumped)

regiontog avatar May 29 '19 13:05 regiontog

That's interesting which test did you run? I tried the spawn_bash example but on my machine I never got any valid pointers on the second level even for the first call to iter which immediately segfaulted..

Anyway your results then indicate, that we just check both for null and stop the iterator once that doesn't hold anymore.

1wilkens avatar May 29 '19 18:05 1wilkens

That's interesting which test did you run?

I just ran my DM, I did not check if too closely but I assume it was the initialize_environment called from open_session that ran the iterator to a segfault.

regiontog avatar May 29 '19 19:05 regiontog

Could you rebase this once more on master and I'll merge it. Sorry for the delay :)

1wilkens avatar Jun 03 '19 15:06 1wilkens

Sorry for the delay. It seems the commit history in this PR is messed up after the merges (duplicate commits). I tried to squash some commits but failed (at least in short time). Either you start from the current master and try to integrate your changes or I will do so in some time as I would still like to have the API. Anyway, I am working on some more refactoring on the branch pam-sys-next so you might want to wait until this hits master anyways. Again sorry for the inconvenience!

1wilkens avatar Nov 20 '19 14:11 1wilkens