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

Unable to enroll second device after enrolling one device (with nanomdm) #232

Open
ashishmeher216 opened this issue Apr 24, 2024 · 5 comments

Comments

@ashishmeher216
Copy link

ashishmeher216 commented Apr 24, 2024

I am getting the error:
remove depot\serial: The process cannot access the file because it is being used by another process.

Is anyone else also facing the same? I read some other issue about data races and it is fixed. #185

From my analysis, the error seems to originate from from writeSerial() function defined in depot/file/depot.go.

func (d *fileDepot) writeSerial(serial *big.Int) error {
if err := os.MkdirAll(d.dirPath, 0755); err != nil {
fmt.Println("🚀 ~ file: depot.go:314 ~ iferr:=os.MkdirAll ~ err:", err)
return err
}
name := d.path("serial")
fmt.Println("🚀 ~ file: depot.go:318 ~ func ~ name:", name) // depot/serial
err := os.Remove(name)
fmt.Println("🚀 ~ file: depot.go:332 ~ func ~ Remove: Removing serial file")
fmt.Println("🚀 ~ file: depot.go:319 ~ func ~ err:", err) // getting error here

file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, serialPerm)
if err != nil {
	return err
}
defer file.Close()

if _, err := file.WriteString(fmt.Sprintf("%x\n", serial.Bytes())); err != nil {
	os.Remove(name)
	return err
}
return nil

}

@jessepeterson
Copy link
Member

What OS are running the SCEP server on? You may want to try mysqlscepserver. We don't have a way to try the BoltDB backend with the stand-alone server. I'll see if I can find some time to test this. Also you can give step-ca a try.

@ashishmeher216
Copy link
Author

Hey @jessepeterson, thanks for the quick reply. I am running the SCEP server on windows for testing purpose.
You can test this by connecting nanomdm with this SCEP server and then enrolling more than one device.

Sure, I will try the two scep servers you mentioned.

@jessepeterson
Copy link
Member

Ah, Windows. Yes there may be a bug where we did not account for Windows file locking semantics in the storage backend. Linux doesn't have this issue afaik.

@ashishmeher216
Copy link
Author

Haha, i know right. Will check it once on linux.

@ashishmeher216
Copy link
Author

This is working on linux machine. I also tested mysqlscepserve and it is working. Thanks.

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

No branches or pull requests

2 participants